Skip to content

Commit

Permalink
watchEffect和computed的差异
Browse files Browse the repository at this point in the history
  • Loading branch information
Panyue-genkiyo committed Oct 13, 2021
1 parent 00e2bb9 commit d261a1f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 10_src_watchEffect函数/components/Demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export default {
watchEffect(() => {
console.log(`watch effect指定的回调执行了!!`)
//依赖收集,你用到了谁它就监视谁!!
//这里用到sum了
//这里用到sum, person.job.j1.salary了,所以可以被监视到(只要它们发生变化就重新执行watchEffect)
//与computed有点类似,依赖收集.(侧重点不一致,watchEffect注重过程,而computed注重计算函数的返回值)
const x1 = sum.value;
const x2 = person.job.j1.salary;
})
Expand Down

0 comments on commit d261a1f

Please sign in to comment.