From d48599e23a0bf8e1fa4365963fa5ee7b4ae452aa Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 8 Mar 2021 21:03:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=BB=98=E8=AE=A4populate=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/widget.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/widget.js b/src/core/widget.js index a7017c403..82f8fd9f5 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -559,6 +559,13 @@ this.element.empty(); }, + // 默认的populate方法就是干掉重来 + populate: function () { + this.empty(); + this.purgeListeners(); + this._init(); + }, + _destroy: function () { this.__d(); this.element.destroy(); From af7615aad7e97dc38dbafca0a5bd394dc53c565e Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 8 Mar 2021 21:16:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=BB=98=E8=AE=A4populate=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/widget.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/core/widget.js b/src/core/widget.js index 82f8fd9f5..0af5b6d90 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -125,6 +125,22 @@ callLifeHook(this, "created"); }, + _initCurrent: function () { + var o = this.options; + if (o._baseCls || o.baseCls || o.extraCls || o.cls) { + this.element.addClass((o._baseCls || "") + " " + (o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || "")); + } + if (o.attributes) { + this.element.attr(o.attributes); + } + if (o.data) { + this.element.data(o.data); + } + if (o.css) { + this.element.css(o.css); + } + }, + /** * 初始化根节点 * @private @@ -152,18 +168,7 @@ this.element = BI.Widget._renderEngine.createElement(this); } this.element._isWidget = true; - if (o._baseCls || o.baseCls || o.extraCls || o.cls) { - this.element.addClass((o._baseCls || "") + " " + (o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || "")); - } - if (o.attributes) { - this.element.attr(o.attributes); - } - if (o.data) { - this.element.data(o.data); - } - if (o.css) { - this.element.css(o.css); - } + this._initCurrent(); }, _initElementWidth: function () { @@ -561,9 +566,11 @@ // 默认的populate方法就是干掉重来 populate: function () { - this.empty(); this.purgeListeners(); + this.empty(); + this._initCurrent(); this._init(); + this._initRef(); }, _destroy: function () {