customDialog使用组件外的builder会报错
promptAction.openCustomDialog({
builder: () => {
customDialogComponent
},
isModal: false,
width: 126,
height: 66,
background color: '#00fffff',
backgroundBlurStyle: BlurStyle.NONE,
cornerRadius: 0,
})
Module name:com.example.myapplication
Version:1.0.0
Version Code: 10000
PreInstalled:No
Foreground:No
Pid:19499
Uid:20020015
Reason:TypeError
Error name:TypeError
Error message:Cannot read property observeComponentCreation2 of undefined
SourceCode:
(parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) =\> {
Stacktrace:
at customDialogComponent (entry/src/main/ets/pages/Index.ets:97:31)
at builder (entry/src/main/ets/pages/Index.ets:133:17)
builder需要赋值为箭头函数,格式如下:() =\> { this.XXX() },其中XXX是内部builder名。
如果是全局builder需要在组件内部创建一个builder,在内部builder中调用全局builder。
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-promptaction-V5\#customdialogoptions11