MCPcopy Create free account
hub / github.com/ygs-code/vue / createComputedGetter

Function createComputedGetter

vue.js:5118–5136  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

5116
5117 //创建计算属性 获取值 收集 dep 依赖
5118 function createComputedGetter(key) {
5119 return function computedGetter() {
5120 // Watcher 实例化之后的对象
5121 var watcher = this._computedWatchers && this._computedWatchers[key];
5122 if (watcher) {
5123 if (watcher.dirty) {
5124 //this.value 获取值 this.getter
5125 watcher.evaluate(); //评估
5126 }
5127 if (Dep.target) {
5128 //为Watcher 添加 为Watcher.newDeps.push(dep); 一个dep对象
5129 //循环deps 收集 newDeps dep 当newDeps 数据被清空的时候重新收集依赖
5130 watcher.depend();
5131 }
5132 //返回值
5133 return watcher.value
5134 }
5135 }
5136 }
5137
5138 //初始化事件Methods 把事件 冒泡到 vm[key] 虚拟dom 最外层中
5139 function initMethods(vm, methods) {

Callers 1

defineComputedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected