Argument of type ‘{ topLeftRadius: number; topRightRadius: number; }‘ is not assignable to parameter

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 }) 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值