vue v2.5.0源码-双向数据绑定

把option.data转变为vm._data的可观察对象

new Vue => this._init() => initState(vm) => initData(vm) => observe(data) => new Observer(data) => walk(data) => defineReactive(obj, key, value) => dep.depend() =>  

watcher.addDep(dep) => watcher.newDeps.push(dep),dep.addSub(watcher) => dep.subs.push(watcher) =>dep.notify()

建立双向数据绑定

vm.$mount => mountComponent => new Watcher(vm, updateComponent) => updateComponent => render => getter =>建立双向数据绑定

 

 

[1]https://blog.seosiwei.com/detail/22

[2]https://blog.csdn.net/wangweianger/article/details/79826801

[3]https://github.com/liutao/vue2.0-source/blob/master/%E5%8F%8C%E5%90%91%E6%95%B0%E6%8D%AE%E7%BB%91%E5%AE%9A.md

posted @ 2018-09-26 16:41  springmin  阅读(132)  评论(0编辑  收藏  举报