Answer the question
In order to leave comments, you need to log in
Why doesn't router.push work?
It's simple, there is a button:
and a method:
<a @click="exit()">Exit</a>
methods: {
exit () {
localStorage.removeItem('token');
this.$router.push({ path: '/login' }).catch(
err => console.log('catch: ', err)
);
}
}
const router = new Router({
base: '/',
mode: 'history',
routes: [
{
path: '/',
component: Layout,
children: [
{
name: 'Login',
path: 'login',
component: Login,
},
...
]
}]
})
Answer the question
In order to leave comments, you need to log in
Why is there catch ? Did you open the documentation at all?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question