原因1
include绑定的name是组件内的name,不是路由的name,大小写要一致,否则不生效
原因2
菜单层级太多,keep-alive缓存不了三级菜单,需要自己手动处理一下
在路由守卫那里,不管你的层级有几层,to.matched都替换成需要的层级即可
router.beforeEach(async (to, from, next) => {
//逻辑代码.....
console.log('路由守卫==========', to.matched);
// 无路由,404
if (to.matched.length === 0) {
from.name ? next({ name: from.name }) : next("/404");
} else {
if (to.matched && to.matched.length > 2) {
to.matched.splice(1, to.matched.length - 2)
}
next();
}
})