根组件定义方法属性,使用provide导出
import {provide, ref} from "vue";
const path=ref('')
const menusClick = (data) => {
path.value=data.index
};
provide('menusClick',menusClick)
provide('path',path)
后代节点——使用inject接收属性、方法并使用
import { inject} from "vue";
const path = inject('path') // 接收
const menusClick = inject('menusClick');