Browse Source

整理代码

es6
guy 3 years ago
parent
commit
553e6d7159
  1. 27
      src/core/4.widget.js

27
src/core/4.widget.js

@ -104,11 +104,28 @@
_initRender: function () { _initRender: function () {
var self = this; var self = this;
var initCallbackCalled = false;
function render () { var renderCallbackCalled = false;
function init () {
// 加个保险
if (initCallbackCalled === true) {
_global.console && console.error("组件: 请检查beforeInit内部的写法,callback只能执行一次");
return;
}
initCallbackCalled = true;
function render () {
// 加个保险
if (renderCallbackCalled === true) {
_global.console && console.error("组件: 请检查beforeRender内部的写法,callback只能执行一次");
return;
}
renderCallbackCalled = true;
self._render();
}
if (self.options.beforeRender || self.beforeRender) { if (self.options.beforeRender || self.beforeRender) {
self.__async = true; self.__async = true;
(self.options.beforeRender || self.beforeRender).call(self, BI.bind(self._render, self)); (self.options.beforeRender || self.beforeRender).call(self, render);
} else { } else {
self._render(); self._render();
} }
@ -116,9 +133,9 @@
if (this.options.beforeInit || this.beforeInit) { if (this.options.beforeInit || this.beforeInit) {
this.__asking = true; this.__asking = true;
(this.options.beforeInit || this.beforeInit).call(this, render); (this.options.beforeInit || this.beforeInit).call(this, init);
} else { } else {
render(); init();
} }
}, },

Loading…
Cancel
Save