Argument of type '{ topLeftRadius: number; topRightRadius: number; }' is not assignable to parameter of type 'Length | BorderRadiuses | LocalizedBorderRadiuses'. Object literal may only specify known properties, and 'topLeftRadius' does not exist in type 'Resource | BorderRadiuses | LocalizedBorderRadiuses'. <ArkTSCheck>
类型为 “{topLeftRadius: number; topRightRadius: number;}” 的参数不能赋给类型为 “Length | BorderRadiuses | LocalizedBorderRadiuses” 的参数。对象字面量只能指定已知的属性,并且 “topLeftRadius” 在类型 “Resource | BorderRadiuses | LocalizedBorderRadiuses” 中不存在。<ArkTSCheck>
Text(item)
.fontColor(Color.White)
.margin({ left: 8 })
.onClick(() => {
this.TxtIndex = index;
})
.borderRadius({topLeftRadius: 10,topRightRadius: 10})
})
根据报错信息,.borderRadius({topLeftRadius: 10,topRightRadius: 10}) 存在类型不匹配的问题。Text 组件的 .borderRadius 属性期望一个 Length 类型的值,或者一个符合 BorderRadiuses 或 LocalizedBorderRadiuses 接口的对象。然而,{topLeftRadius: 10,topRightRadius: 10} 这个对象字面量中,属性名 topLeftRadius 和 topRightRadius 不被 BorderRadiuses 或 LocalizedBorderRadiuses 类型所接受。 为了解决这个问题,你需要确保传递给 .borderRadius 属性的对象,其属性是 BorderRadiuses 类型所定义的。在 BorderRadiuses 类型中,通常包括 topLeft、topRight、bottomLeft 和 bottomRight 这样的属性。所以,你的代码应该改成这样
Text(item)
.fontColor(Color.White)
.margin({ left: 8 })
.onClick(() => {
this.TxtIndex = index;
})
.borderRadius({ topLeft: 10, topRight: 10 })