0
我遇到了這個問題,我不能使用next('/login')
。這是我的代碼:Vue路由器beforeEach在使用next()時陷入死循環
*/ all imports that are needed
Vue.use(Router);
const routes = [
{path: '/', component: Home},
{path: '/admin', component: Admin},
{path: '/login', component: Login}]
var route = new Router({
routes: routes,
mode: 'history' });
route.beforeEach((to, from , next) => {
console.log(to.fullPath)
next('/login');
});
new Vue({
el: '#app',
router: route,
template: '<App/>',
components: {
App
}
})
它工作時,我只用next()的,但是當我給next()函數的路線它把一個無限循環
謝謝!這解決了它 –