vue3,父孙组件通信
时间: 2023-09-28 18:08:21 浏览: 103
在Vue3中,父组件向孙组件通信可以通过使用Provide/Inject这对API来实现。在父组件中,通过使用provide方法提供数据,然后在孙组件中使用inject方法来接收这些数据。这种方式可以跨越多层组件传递数据,实现父孙组件之间的通信。这样可以在不直接通过props和$emit来传递数据的情况下,实现组件之间的数据共享。具体的使用方法可以参考Vue3的官方文档。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [vue中组件通信详解(父子组件, 爷孙组件, 兄弟组件)](https://download.csdn.net/download/weixin_38736760/13128096)[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: 33.333333333333336%"]
- *2* [Vue中父组件向子组件通信的方法](https://download.csdn.net/download/weixin_38743054/12777066)[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: 33.333333333333336%"]
- *3* [Vue 之孙组件向爷组件通信的实现](https://download.csdn.net/download/weixin_38713996/12943554)[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: 33.333333333333336%"]
[ .reference_list ]
阅读全文