Answer the question
In order to leave comments, you need to log in
How to redirect a page before creating it with vue router?
Here is my code that does what I described:
beforeCreate() {
const session = this.$cookie.get('session');
if(session) this.$router.push('/search-content');
}
Answer the question
In order to leave comments, you need to log in
Perhaps it makes sense to use a router hook. Those. in a component or global transition permission hook use:
beforeRouteEnter (to, from, next) {
const session = this.$cookie.get('session');
if(session) next({path: '/search-content'});
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question