From 182a250c4f5a965a20616c6ac96cb68ef62d507b Mon Sep 17 00:00:00 2001 From: jian Date: Tue, 19 Dec 2023 16:40:41 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-16950=20fix:=20=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fineui/src/core/4.widget.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/fineui/src/core/4.widget.js b/packages/fineui/src/core/4.widget.js index df12ef774..8fe60098a 100644 --- a/packages/fineui/src/core/4.widget.js +++ b/packages/fineui/src/core/4.widget.js @@ -240,8 +240,11 @@ export class Widget extends OB { ).call(this, render); if (beforeRenderResult instanceof Promise) { beforeRenderResult.then(render).catch((e) => { - _global.console && console.error(e); - !this.isDestroyed() && render(); // 异步render,改组件此时可能已经被销毁 + if (!this.isDestroyed()) { + render(); // 异步render,组件此时可能已经被销毁 + } else { + _global.console && console.error(e, 'Async render error! Widget has been destroyed!'); + } }); } } else { @@ -257,8 +260,11 @@ export class Widget extends OB { ).call(this, init); if (beforeInitResult instanceof Promise) { beforeInitResult.then(init).catch((e) => { - _global.console && console.error(e); - !this.isDestroyed() && init(); // 异步render,改组件此时可能已经被销毁 + if (!this.isDestroyed()) { + init(); // 异步init,组件此时可能已经被销毁 + } else { + _global.console && console.error(e, 'Async init error! Widget has been destroyed!'); + } }); } } else { @@ -874,7 +880,7 @@ export class Widget extends OB { this._assetMounted(); this.__destroy(); this.fireEvent(Events.UNMOUNT); - // this._purgeRef(); // 子组件unmount ref置为null了,父组件拿不到ref,导致报错 + this._purgeRef(); // 子组件unmount ref置为null了,父组件拿不到ref,导致报错 this.purgeListeners(); }