HarmonyOS $$双向绑定问题

TextPicker selected 属性是支持双向绑定的属性 , 而单独使用TextPicker 就报了 "Cannot find name '$$this'." 错误 , 但是把注释掉的 TextArea组件打开, 项目就运行起来了, TextPicker selected 双向绑定就可以了。

HarmonyOS
2024-10-17 11:08:12
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

请参考以下demo:

@Entry  
@Component  
struct ToggleExample {  
  @State ison: boolean = false  
  build() {  
    Column({ space: 10 }) {  
      Text('type: Switch').fontSize(12).fontColor(0xcccccc).width('90%')  
      Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {  
        Text(JSON.stringify(this.ison))  
        Toggle({ type: ToggleType.Switch, isOn: $$this.ison })  
          .selectedColor('#007DFF')  
          .switchPointColor('#FFFFFF')  
          .onChange((isOn: boolean) => {  
            console.info('Component status:' + isOn)  
          })  
      }.width('100%').padding(24)  
    }  
  }  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
分享
微博
QQ
微信
回复
2024-10-17 15:17:41
相关问题
HarmonyOS TextInput双向绑定无效
729浏览 • 1回复 待解决
HarmonyOS 无法使用$$双向绑定
1905浏览 • 1回复 待解决
HarmonyOS如何实现双向数据绑定
1498浏览 • 1回复 待解决
ArkTS简单类型变量双向数据绑定
2719浏览 • 1回复 待解决
字母表与侧标滚动栏的双向绑定
1412浏览 • 1回复 待解决
HarmonyOS socket 绑定IP问题
819浏览 • 1回复 待解决