HarmonyOS CustomDialog怎么把弹窗封装到某个类的方法中?

自定义的弹窗,怎么在封装的类中调用。比如下面的写法,这个方法show是有问题的。

@CustomDialog
struct CustomDialogExample {
  controller?: CustomDialogController
  build() {
    Column() {
      Text('我是内容').fontSize(16).margin({ bottom: 10 })
    }
  }
}

@Builder
export function builderPageFunc(): void {
  CustomDialogExample();
}
export class Hud{
  static show(){
    let option : CustomDialogControllerOptions = {
      builder:builderPageFunc()
    }
    let dialogController: CustomDialogController  = new CustomDialogController(option);
    dialogController.open()
  }
}
阅读 474
1 个回答

目前CustomDialog不支持在class中封装,因为弹窗需要根据上下文来弹出。

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