router里的index.js
{ //账套-基本信息管理
path: '/home/zhangtao/base_message_manage',
name: '',
component: resolve => require(['@/pages/zhangtao/base_message_manage'], resolve),
meta:{
keepAlive:false
}
},
router.beforeEach((to,from,next)=>{
if (to.path == "/entry_company_message" ||to.path == "/password_login" || to.path == "/" || to.path == "/forget_password" || to.path == "/bind_phone") {
next()
}else{
if (localStorage.getItem('user')) {
if(to.path == "/home/zhangtao/kemushezhi"){
alert(2)
from.meta.keepAlive = true
}
if(to.path == "/home/zhangmian/index" && to.query.no){
console.log(from)
from.meta.keepAlive = false
}
next()
}else{
next()
// setTimeout(()=>{
// alert('登陆过期')
next({path:'/'})
// },2000)
}
}
// if (to.path != "/password_login") {
// if (localStorage.getItem('user')) {
// next()
// }else{
// next()
// if(to.path == "/" || to.path == "/forget_password"){
//
// }else{
// setTimeout(()=>{
// alert('登陆过期')
// next({path:'/password_login'})
//
// },2000)
// }
//
// }
// }else{
// next()
// }
})
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>