keep-alive缓存组件,三级菜单组件无法缓存问题解决

后台管理菜单列表三级菜单无法缓存组件问题,根本原因是在于keep-alive本身存在的缺陷,需要在路由守卫中将matched属性做一下优化,具体如下

Router.beforeEach((to, from, next)=>{
    
    
	if(to.matched && to.matched.length>2){
    
    
		to.matched.splice(1,to.matched.length -2)
	}
	next()
})

在路由勾子上添加如上代码解决keep-alive缓存问题

猜你喜欢

转载自blog.csdn.net/weixin_47818125/article/details/126947593
今日推荐