main.ts
import mitt from 'mitt'
const vueEvent = mitt()
app.config.globalProperties.vueEvent = vueEvent
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') })