vue3兄弟组件传值
作者:互联网
import {getCurrentInstance} from 'vue' const vueEvent = getCurrentInstance()?.appContext.config.globalProperties.vueEvent //发送 vueEvent.emit('handleCurrentNo', 1) //接收 onMounted(() => { vueEvent.on('handleCurrentNo', (val: number) => { state.currentNo = val }) }) onUnmounted(() => { vueEvent.off('handleCurrentNo') })
标签:getCurrentInstance,val,onMounted,number,vueEvent,handleCurrentNo,vue3,组件,传值 来源: https://www.cnblogs.com/daifuchao/p/15029995.html