diff --git a/examples/dev.html b/examples/dev.html
index 092b90c16..009f32b8d 100644
--- a/examples/dev.html
+++ b/examples/dev.html
@@ -2,7 +2,7 @@
-
+
@@ -24,6 +24,13 @@
height: 200,
width: 600
},
+ beforeInit: function () {
+ return new Promise(function (resolve) {
+ setTimeout(function () {
+ resolve();
+ }, 1000);
+ });
+ },
_store: function () {
return BI.Models.getModel("demo.model");
},
@@ -49,7 +56,7 @@
type: "bi.button",
text: "点击",
handler: function () {
- store.model.columnSize = [300, "fill"]
+ store.model.columnSize = [300, "fill"];
}
}]
}]
diff --git a/src/core/4.widget.js b/src/core/4.widget.js
index c3d1e0bc5..dc347665e 100644
--- a/src/core/4.widget.js
+++ b/src/core/4.widget.js
@@ -133,7 +133,10 @@
if (self.options.beforeRender || self.beforeRender) {
self.__async = true;
- (self.options.beforeRender || self.beforeRender).call(self, render);
+ var beforeRenderResult = (self.options.beforeRender || self.beforeRender).call(self, render);
+ if (beforeRenderResult instanceof Promise) {
+ beforeRenderResult.then(init);
+ }
} else {
self._render();
self.__afterRender();
@@ -142,7 +145,10 @@
if (this.options.beforeInit || this.beforeInit) {
this.__asking = true;
- (this.options.beforeInit || this.beforeInit).call(this, init);
+ var beforeInitResult = (this.options.beforeInit || this.beforeInit).call(this, init);
+ if (beforeInitResult instanceof Promise) {
+ beforeInitResult.then(init);
+ }
} else {
init();
}