HarmonyOS @Builder 按引用传递参数编译错误?

如题:HarmonyOS @Builder 按引用传递参数编译错误?

阅读 555
1 个回答

问题场景

编译提示:Object literals cannot be used as type declarations (ArkTS-no-obj-literals-as-types) <ArkTSCheck\>

代码:

@Builder overBuilder($$: { paramA1: string }) {
  Row() {
    Text(`UseStateVarByReference: ${$$.paramA1} `)
  }

参考代码:

class Tmp{
  paramA1:string = ‘’
}
@Builder function overBuilder($$ : Tmp) {
  Text($$.params)
    .width(400)
    .height(50)
    .backgroundColor(Color.Blue)
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进