Browse Source

增加组件默认populate方法

es6
guy 4 years ago
parent
commit
af7615aad7
  1. 33
      src/core/widget.js

33
src/core/widget.js

@ -125,6 +125,22 @@
callLifeHook(this, "created"); 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 * @private
@ -152,18 +168,7 @@
this.element = BI.Widget._renderEngine.createElement(this); this.element = BI.Widget._renderEngine.createElement(this);
} }
this.element._isWidget = true; this.element._isWidget = true;
if (o._baseCls || o.baseCls || o.extraCls || o.cls) { this._initCurrent();
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);
}
}, },
_initElementWidth: function () { _initElementWidth: function () {
@ -561,9 +566,11 @@
// 默认的populate方法就是干掉重来 // 默认的populate方法就是干掉重来
populate: function () { populate: function () {
this.empty();
this.purgeListeners(); this.purgeListeners();
this.empty();
this._initCurrent();
this._init(); this._init();
this._initRef();
}, },
_destroy: function () { _destroy: function () {

Loading…
Cancel
Save