Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ec-canvas.js): 针对lazyLoad的情况,防止init在视图层ready之前被触发 #560

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ec-canvas/ec-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@ Component({
return;
}

this._isReady = true;
if (!this.data.ec.lazyLoad) {
this.init();
} else { // 针对lazyLoad的 init 必须在ready之后
if (this._pendingInitCb) {
this.init(this._pendingInitCb);
}
}
},

methods: {
init: function (callback) {
if (!this._isReady) {
this._pendingInitCb = callback;
return;
}

const version = wx.version.version.split('.').map(n => parseInt(n, 10));
const isValid = version[0] > 1 || (version[0] === 1 && version[1] > 9)
|| (version[0] === 1 && version[1] === 9 && version[2] >= 91);
Expand Down