vue2如何查看什么导致了computed的重新求值/更新?-灵析社区

Frank的私人司机

computed: { aaa() { console.log(111); debugger; return this.bbb.map(item => this.一个方法(item, this.ccc)); }, aaa会莫名重新计算/调用/更新,不知道是什么导致的,如何快捷地找到是什么导致的 根据我建了个watch(deep)来看,this.bbb并没有变 我看了一些computed原理,但是都没有实际例子,只是在源码上分析,看不懂 * * * 添加断点后,看着往上第4层是这个函数 function createComputedGetter (key) { return function computedGetter () { var watcher = this._computedWatchers && this._computedWatchers[key]; if (watcher) { if (watcher.dirty) { watcher.evaluate();这里 } if (Dep.target) { watcher.depend(); } return watcher.value } } } ![HW$D%0N405ZA2S{YZNB\)$UV.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20241123/b5116239fc28e270e5af3a9fea3c8e28.png) 看起来似乎跟deps有点关系,但是不知道怎么看

阅读量:17

点赞量:0

问AI
CO_co
监听一下: watch: { ccc(newVal, oldVal) { console.log('ccc changed!', newVal, oldVal); } }