Open henrycjchen opened 4 years ago
computed: { a() { return this.b } }
依赖收集时,针对 a,先将 key a 放到全局如 window.depKey = 'a',执行函数 a,此时函数中 return this.b 会触发 b defineProperty 中的 get 方法,并将 window.depKey 放到 b 的依赖列表中。
key a
window.depKey = 'a'
函数 a
此后,当 b 修改时,便会遍历触发 b 的依赖列表的 key 的数据更新
依赖收集时,针对 a,先将
key a
放到全局如window.depKey = 'a'
,执行函数 a
,此时函数中 return this.b 会触发 b defineProperty 中的 get 方法,并将 window.depKey 放到 b 的依赖列表中。此后,当 b 修改时,便会遍历触发 b 的依赖列表的 key 的数据更新