const safeTop = () => {
const safe = uni.getSystemInfoSync().safeArea
return safe.top
}
safeTop()
19:26:00.028 [plugin:uni:app-uts] 编译失败
19:26:00.030 error: 类型不匹配: 推断类型是Number,但预期的是Unit。
19:26:00.030 at pages/index/index.uvue:7:9
19:26:00.030 5 | const safeTop = () => {
19:26:00.030 6 | const safe = uni.getSystemInfoSync().safeArea
19:26:00.030 7 | return safe.top
19:26:00.030 | ^
19:26:00.030 8 | }
19:26:00.030 9 | safeTop()
8***@qq.com (作者)
感谢大佬,我看编辑器类型推断已经推断出来了,居然还要手动添加
2024-05-30 19:33