diff --git a/src/core/widget.js b/src/core/widget.js index f43bffce0..cce4c4b3f 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -59,9 +59,11 @@ } }, + // 生命周期函数 beforeInit: null, - // 生命周期函数 + beforeRender: null, + beforeCreate: null, created: null, @@ -94,14 +96,24 @@ }, _initRender: function () { + var self = this; + + function render () { + if (self.options.beforeRender || self.beforeRender) { + (self.options.beforeRender || self.beforeRender).call(this, BI.bind(self._render, this)); + } else { + self._render(); + } + } + if (this.options.beforeInit || this.beforeInit) { this.__asking = true; - (this.options.beforeInit || this.beforeInit).call(this, BI.bind(this._render, this)); + (this.options.beforeInit || this.beforeInit).call(this, render); if (this.__asking === true) { this.__async = true; } } else { - this._render(); + render(); } },