中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
微信扫码分享
@Entry @Component struct Index { @State select: boolean = true private iconStr: ResourceStr = `$r("app.media.icon")` @Builder MyMenu(){ Menu() { MenuItem({ startIcon: `$r("app.media.icon")`, content: "菜单选项" }) .enabled(false) MenuItem({ startIcon: this.iconStr, content: "菜单选项", }) } } build() { Row() { Column() { Text('呼出菜单') .fontSize(20) .fontWeight(FontWeight.Bold) } .bindMenu(this.MyMenu) .width('100%') } .height('100%') } } 40.按引用传递参数时如何引起@Builder方法内的UI刷新? class Tmp { paramA1: string = ' ' } @Builder function overBuilder(params: Tmp) { Row() { Text(`UseStateVarByReference: ${params.paramA1} `) } } @Entry @Component struct Parent { @State label: string = 'Hello'; build() { Column() { overBuilder({ paramA1: this.label }) Button('Click me').onClick(() => { this.label = 'ArkU213123I'; }) } } }