報錯
Error name:TypeError Error message:is not callable Stacktrace: at PUV2ViewBase (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4029:1) at ViewPU (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:6213:1) at WheelPickerDialog (entry/src/main/ets/common/widgets/dialog/WheelPickerDialog.ets:8:1) at showUniversalDialog (entry/src/main/ets/common/utils/WheelPickerUtils.ets:13:20) at showSocPicker (entry/src/main/ets/common/utils/WheelPickerUtils.ets:107:22) at showSocPicker (entry/src/main/ets/pages/car/OutDisChargeElePage.ets:564:22) at anonymous (entry/src/main/ets/pages/car/OutDisChargeElePage.ets:242:18) at anonymous (entry/src/main/ets/pages/car/OutDisChargeElePage.ets:367:9)
/**
* 顯示通用選擇器
* @param options 配置選項
*/
static showUniversalDialog(options: WheelPickerOptions) {
const dialog = new WheelPickerDialog({
title: options.title || '選擇',
positiveText: options.positiveText || '確認',
negativeText: options.negativeText || '取消',
showPositive: options.showPositive ?? true,
showNegative: options.showNegative ?? true,
pickerConfigs: options.columns,
onConfirmCallback: (...values: string[]) => {
if (options.onConfirm) {
options.onConfirm(...values)
}
},
onCancelCallback: () => {
if (options.onCancel) {
options.onCancel()
}
}
})
const controller = new CustomDialogController({
builder: dialog,
autoCancel: true,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: 0 },
customStyle: true,
gridCount: 4
})
dialog.controller = controller
controller.open()
}
一調(diào)用這個方法就崩潰,這個問題的根本原因是不能在工具類中彈dialog導致的,代碼放到page頁面中就沒問題了,在 Page 中創(chuàng)建 Controller:CustomDialogController 必須在 Page 組件中創(chuàng)建和打開
另外目前測試頁面的彈窗不能這樣單獨創(chuàng)建dialog:

必須要放到方法builder里面創(chuàng)建:

否則就會崩潰。

工具類中這樣寫彈窗也彈不出來,所以彈窗不要封裝工具類,直接在頁面創(chuàng)建,這兩天算是好好踩踩坑,摸索一下。