vue3 setup语法糖中的watch
时间: 2023-10-25 22:08:04 浏览: 93
Vue3语法学习笔记
在Vue3的setup语法糖中,可以使用watch函数来监听数据的变化。watch函数接受两个参数,第一个参数是要监听的值,可以是单个值或者是一个数组包含多个值。第二个参数是一个回调函数,当监听的值发生变化时,这个回调函数会被调用。回调函数接收两个参数,分别是新值和旧值。通过在回调函数中编写副作用逻辑,可以实现对数据变化的响应。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [【vue3】vue3 setup如何使用watch?](https://blog.csdn.net/qq_39576711/article/details/123685240)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [vue3学习笔记-setup中使用watch](https://blog.csdn.net/weixin_52720619/article/details/125224110)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文