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

模拟代码错误 #62

Open
lazyunderscore opened this issue Nov 18, 2019 · 1 comment
Open

模拟代码错误 #62

lazyunderscore opened this issue Nov 18, 2019 · 1 comment

Comments

@lazyunderscore
Copy link

开始依赖收集
class Vue { constructor(options) { this._data = options.data; observer(this._data, options.render); let watcher = new Watcher(this, ); } }

  1. watcher的定义应该在observer之前,否则,defineReactive 无法获被添加到watcher
  2. watcher定义缺少参数
@lazyunderscore
Copy link
Author

我理解错了。看样子是第一次执行observe,是不会收集到依赖。new wathcer 的时候触发getter, 这时候,在getter执行的时候,收集到依赖。这是可行的。但是那个Dep.target的重置为null的操作,不知道为什么放到外边来。new Vue之后,应该就可以重置为null了。

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

No branches or pull requests

1 participant