$on,$off,$emit
时间: 2023-08-30 07:08:53 浏览: 73
在Vue中,$on用于在一个组件中监听一个事件,并在事件触发时执行回调函数。回调函数可以接收传递给事件的数据作为参数。而$emit则用于在一个组件中触发一个事件,并且可以传递数据给监听该事件的组件。另外,$off用于取消对一个事件的监听。通过调用$off并传递事件名称和回调函数,可以将该事件的监听取消掉。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [vue中$refs, $emit, $on, $once, $off的使用详解](https://download.csdn.net/download/weixin_38651983/12941773)[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_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [$emit,$on,$off--vue](https://blog.csdn.net/weixin_57844432/article/details/126599659)[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_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [vue中$bus的用法及$emit、$on、$off的使用](https://blog.csdn.net/leijie0322/article/details/128210817)[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_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文