HarmonyOS 鸿蒙Next State的变量无法监听到值的变化
HarmonyOS 鸿蒙Next State的变量无法监听到值的变化
ILoginUiService.instance()?.getAccountSelectComponent().builder({ visible: this.param.visible }) @State param: AccountDialogData = new AccountDialogData(); @Observed export class AccountDialogData { visible: boolean = false; } getAccountSelectComponent(): WrappedBuilder<[AccountDialogData]> { return wrapBuilder(AccountSelectComponentBuilder) } } @Builder function AccountSelectComponentBuilder(accountDialogData: AccountDialogData) { AccountSelectMiddleView({ accountDialogData: accountDialogData }); } 在AccountSelectMiddleView中无法监听到AccountDialogData.visible.的变化??请问是哪里弄错了,谢谢
2 回复
可以参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-state-V5#观察变化和行为表现
可以通过router.getParams();接收参数,
onPageShow() {
this.routerParams = router.getParams() as Record<string, string>
if (this.routerParams !== undefined && this.routerParams !== null) {
} else {
}
}