Is there any way to customize the 'beforeEach' hook of vue-router?
[issue link]I want to do login auth in spa mode by adding a ‘beforeEach’ hook of vue-router, and I have not found any description about the hook of vue-router in the doc of nuxt. Is there any way to customize the ‘beforeEach’ hook of vue-router?
The code works in a webpack template is like this:
import Router from 'vue-router'
const router = new Router({
// ...
})
router.beforeEach((to, from, next) => {
if(!localStorage.getItem('userId')) {
next('/login');
} else {
next();
}
}
new Vue({
el: '#app',
router,
render: h => h(App)
}).$mount('#app')