MCPcopy Index your code
hub / github.com/ygs-code/vue / initWatch

Function initWatch

vue.js:5175–5198  ·  view source on GitHub ↗
(vm, watch)

Source from the content-addressed store, hash-verified

5173
5174 //初始化Watch监听
5175 function initWatch(vm, watch) {
5176 //循环watch对象
5177 for (var key in watch) {
5178 var handler = watch[key]; //获取单个watch
5179 //如果他是数组handler
5180 if (Array.isArray(handler)) {
5181 //循环数组 创建 监听
5182 for (var i = 0; i < handler.length; i++) {
5183 createWatcher(
5184 vm, //vm 是 vue对象
5185 key, //key
5186 handler[i]//函数或者对象
5187 );
5188 }
5189 } else {
5190 //循环数组 创建 监听
5191 createWatcher(
5192 vm, // vm 是 vue对象
5193 key, //key
5194 handler //函数或者对象
5195 );
5196 }
5197 }
5198 }
5199
5200 // 转义handler 并且为数据 创建 Watcher 观察者
5201 function createWatcher(vm, //vm对象

Callers 1

initStateFunction · 0.85

Calls 1

createWatcherFunction · 0.85

Tested by

no test coverage detected