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

onLoad重复setdata #71

Open
wwwjason1994 opened this issue Mar 8, 2019 · 0 comments
Open

onLoad重复setdata #71

wwwjason1994 opened this issue Mar 8, 2019 · 0 comments

Comments

@wwwjason1994
Copy link

@wwwjason1994 wwwjason1994 commented Mar 8, 2019

在外部onload中this.setData或者this.update,都会因create.js里的onload封装导致触发了两次setdata

然后页面下的组件页用create的话,就会在ready在触发一次setdata。

但是onLoad里的setData是异步的话应该没问题

可以把onLoad && onLoad.call(this, e)移到最后触发能,这样会不会带来什么影响?

问题代码:

option.onLoad = function (e) {
            this.store = store
            this._updatePath = updatePath
            rewriteUpdate(this)
            store.instances[this.route] = []
            store.instances[this.route].push(this)
            onLoad && onLoad.call(this, e)
            syncValues(store.data, this.data)
            this.setData(this.data)
        }
// to
option.onLoad = function (e) {
            //...
            syncValues(store.data, this.data)
            this.setData(this.data)
            onLoad && onLoad.call(this, e)
        }

ready也一样,在我做echart图表的时候因为,因为数据量大的原因重复setdata会重复刷新canvas

即使我像上面一样把onLoad && onLoad.call(this, e)移后,ready也会再触发一次,所以,组件上我只能用纯组件(Components)了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.