HarmonyOS 在组件的appear中去设置AttributeModifier或者GestureModifier不会触发UI刷新,貌似跟reuse有关系,加上这个标记后就会失效,帮忙确认下失效原因?

代码片段:

@Entry
@Component
@Reusable
struct Index {
  // modifier: MyButtonModifier = new MyButtonModifier()
  state: State = new State()
  build() {
    Row() {
      Column() {
        Button('切换')
          .onClick(() => {
            if (this.state.modifier.supportDoubleTap.supportDoubleTap) else
            {
              this.state.modifier.supportDoubleTap = {
                supportDoubleTap: true
              }
              this.state.mod.isDark = false
            }
          })
        Column() {
          Text('111')
            .onAppear(() => {
              this.state.mod.isDark = true
              this.state.modifier.supportDoubleTap = {
                supportDoubleTap: false
              }
            })
        }
        .gestureModifier(this.state.modifier)
        .width(500)
        .height(500)
        ...
阅读 507
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进