Answer the question
In order to leave comments, you need to log in
Vue. How to put two routes on one button?
Hello. Let's say there is a layout, the content changes by replacing components, depending on which route.
At the very bottom of the layout there is a button "Continue"
<router-link tag="button" :to="{name: 'catalog', params: {module: 'view-1'}}">
Продолжить
</router-link>
Answer the question
In order to leave comments, you need to log in
Make the parameter value to
dependent on the current route:
computed: {
catalogRoute() {
return {
name: 'catalog',
params: {
module: this.$route.name === 'catalog'
? this.$route.params.module.replace(/\d+/, m => +m + 1)
: 'view-1',
},
};
},
},
<router-link :to="catalogRoute">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question