1、官网写法:
2、个人写法
备注:因菜单较多,90%重复,新增、编辑不同
1.创建菜单(菜单路径跟隐藏菜单的前端组件地址一样)
菜单路径/Res/1,其中这个1为随机数(可以根据个人定义)
2、新增一个隐藏路由
/Res/:resType: (resType为变量)
3、怎么拿到这个菜单路径
created () {
this.initByPath()
},
watch: {
'$route.path' (newVal, oldVal) {
if (newVal !== oldVal) {
this.activeObj = {}
this.initByPath()
}
}
},
methods: {
initByPath () {
let that = this;
let routeParams = this.$route.params
//routeParams.resType 为变量,拿到这个值,就可以判断是那个菜单
if (routeParams && routeParams.resType) that.curType = routeParams.resType
console.log('----------------------更换ResouceTypeId:',routeParams);
},