未验证 提交 8e88f87d 编写于 作者: O openharmony_ci 提交者: Gitee

!15364 修改customDialog示例代码,示例写法会导致内存泄漏

Merge pull request !15364 from zhaoxinyu/modifyCustomDialogSample
...@@ -108,6 +108,11 @@ struct CustomDialogUser { ...@@ -108,6 +108,11 @@ struct CustomDialogUser {
customStyle: false customStyle: false
}) })
aboutToDisappear() {
delete this.dialogController,
this.dialogController = undefined
}
onCancel() { onCancel() {
console.info('Callback when the first button is clicked') console.info('Callback when the first button is clicked')
} }
...@@ -124,7 +129,9 @@ struct CustomDialogUser { ...@@ -124,7 +129,9 @@ struct CustomDialogUser {
Column() { Column() {
Button(this.inputValue) Button(this.inputValue)
.onClick(() => { .onClick(() => {
this.dialogController.open() if (this.dialogController != undefined) {
this.dialogController.open()
}
}).backgroundColor(0x317aff) }).backgroundColor(0x317aff)
}.width('100%').margin({ top: 5 }) }.width('100%').margin({ top: 5 })
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册