Dep.target = null;
var targetStack = [];
function **pushTarget** (_target) {
if (Dep.target) { targetStack.push(Dep.target); }
Dep.target = _target;
}
function **popTarget** () {
Dep.target = targetStack.pop();
}
Watcher.prototype.get = function get () {
**pushTarget(this)**;
var value;
var vm = this.vm;
if (this.user) {
} else {
}
if (this.deep) {
}
**popTarget();**
this.cleanupDeps();
return value
};
求教这样做的目的是什么? 不能在选择依赖属性完直接将Dep.target设置为null吗?
慕少森
相关分类