这是 Composition API 的常见疑问:
比较项computedwatch用途派生值监听副作用返回值有无(需手动触发)响应式依赖自动收集手动指定执行时机初始化不执行副作用可设 immediate
简单判断:
- 需要“值”用 computed(如格式化、筛选)
- 需要“动作”用 watch(如发请求、写缓存)
https://www.sohu.com/a/910454515_122459568
https://www.sohu.com/a/910452653_122459568
https://www.sohu.com/a/910451737_122459568
https://www.sohu.com/a/910448988_122459568
https://www.sohu.com/a/910448961_122459568
https://www.sohu.com/a/910458110_122459559
https://www.sohu.com/a/910457842_122459559
https://www.sohu.com/a/910457817_122459559
https://www.sohu.com/a/910457046_122459559
https://www.sohu.com/a/910458790_122459428
https://www.sohu.com/a/910459091_122459428
https://www.sohu.com/a/910459366_122459428
https://www.sohu.com/a/910459848_122459428
https://www.sohu.com/a/910460703_122459428
https://www.163.com/dy/article/K3J53OBJ0556EC6N.html
https://www.163.com/dy/article/K3J57DDV0556EC6N.html
https://blog.csdn.net/gregg4265117/article/details/149105176
https://blog.csdn.net/gregg4265117/article/details/149105010?
https://blog.csdn.net/gregg4265117/article/details/149105232
https://blog.csdn.net/gregg4265117/article/details/149105255
https://blog.csdn.net/gregg4265117/article/details/149105276