router.beforeEach((to, from, next) => {
// 获取token
const tokenStr = localStorage.getItem('token')
if (to.path === '/' && tokenStr ) {
next('/index')
}else{
next()
}
if (!tokenStr) {
return next('/')
}else{
next()
}
})