main.js写路由前置守卫router.beforeEach
但是免登录一直是拿不到localstorage里面的信息进行操作
把router.beforeEach放到router文件夹下的index.js又恢复正常,于是就知道可能是路由没被写好Vue就已经被new出来初始化了,不难,是粗心
正常顺序应该是
import router from './router'
Vue.use(router)
router.beforeEach((to,from,next)=>{???})
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})