android是不支持 lang="uts" setup 吗
![艾璞](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/001/17/03/29_avatar_mid.jpg?v=1713149645)
- 发布:2024-04-15 13:21
- 更新:2025-01-10 11:06
- 阅读:211
script lang="uts" setup 中在android中无法使用defineProps
![艾璞](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/001/17/03/29_avatar_mid.jpg?v=1713149645)
艾璞 (作者)
代码 Hbuildx版本号:4.12.2024041009-alpha
<template>
<view class="ch_row" :style="getRowStyle()">
<slot></slot>
</view>
</template>
<script lang="uts" setup>
const props = defineProps({
gutter: {
type: [String, Number],
default: () => 0
}
})
const getRowStyle = () => {
return new Map<string, string>([['padding', `${props.gutter}px 0 0 ${props.gutter}px`]])
}
provide('row_gutter', props.gutter);
</script>
<style>
.ch_row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
</style>
![DCloud_UNI_FengXY](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/000/86/60/87_avatar_mid.jpg?v=1727611674)
注意根据报错修改代码,有两处错误,都是缺少返回类型
<script lang="uts" setup>
const props = defineProps({
gutter: {
type: [String, Number],
default: () : number => 0
}
})
const getRowStyle = () : Map<string, string> => {
return new Map<string, string>([['padding', `${props.gutter}px 0 0 ${props.gutter}px`]])
}
provide('row_gutter', props.gutter);
</script>
-
艾璞 (作者)
这个我改过不是这个的问题哦 还是会报错error: The integer literal does not conform to the expected type Unit
2024-04-15 13:48
-
-
-
![2***@qq.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/7a41517a60914eee46edae7881ef3879.png)
2***@qq.com - 我爱HbuilderX,虽然坑多,但一定会填满!它必将是世界最强跨平台框架!
必须要这么写吗?
const getRowStyle = () => {
return new Map<string, string>([['padding', `${props.gutter}px 0 0 ${props.gutter}px`]])
}
如果这样写不行吗,我看了确实报错,提示类型不匹配,很疑惑:
const getRowStyle = computed(()=>{
return {
padding: `${props.gutter}px 0 0 ${props.gutter}px`
}
})
艾璞 (作者)
代码 Hbuildx版本号:4.12.2024041009-alpha
代码我贴下面了
2024-04-15 13:29