vue3 WATCH
时间: 2023-09-23 15:12:38 浏览: 109
在Vue3中,watch用于监听数据的变化。相比Vue2,Vue3对watch进行了一些改进。在Vue3中,默认开启了深度监视,即使监听的是深层次的数据,也可以监听到其变化。例如,可以使用watch来监视一个数字的变化。比如,定义一个数字变量count,并使用watch来监听其变化。当count发生变化时,watch会触发回调函数,并传入新值和旧值作为参数。在回调函数中,可以对新值和旧值进行处理或执行其他操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Vue3中watch的详解](https://blog.csdn.net/weixin_44590591/article/details/124598751)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [vue3中的watch的用法和几种常见情况](https://blog.csdn.net/weixin_44437816/article/details/124641625)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文