HarmonyOS 自定义组件时传入值时@Prop @Watch没有触发?

当一个组件接收参数

@Prop @Watch('onCountDown') duration: number = 0时,直接调用组件 CountDown({ duration: 10000 }) @Watch('onCountDown')没有触发。

////////////////////////////////////////
setTimeout(() => {
  this.totalSeconds = 10000
}, 100)

CountDown({ duration: this.totalSeconds })

添加定时器让其重新渲染才可以生效,是否有类似于前端VUE框架的watch imediate机制

阅读 440
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进