How to keep active class in navigation at the spa at the vue after reboot?

For me there is menuListItemActiveNumber variable, which by default is set to 0 when clicking on a link in navigation the value of the variable is changed to the corresponding number. Depending on the value of a variable on a particular link jumped a class active. But after reloading the page the active class from the link resets, as menuListItemActiveNumber again equals 0. How to fix it?


April 3rd 20 at 18:36
2 answers
April 3rd 20 at 18:38
this.$route.params returns a object and I need the number to get the number of the rout, or something like that - Estelle commented on April 3rd 20 at 18:41
@Estelle, why not use a standard class? - enid.Lindgren commented on April 3rd 20 at 18:44
@enid.Lindgren, Because it is not thought of. Thank you - Estelle commented on April 3rd 20 at 18:47
April 3rd 20 at 18:40
Use the v-for and a check for $route.path
 li(v-for='(item, index) in [['/Joury', 'jury'], ...]')
 router-link(:to='item[0]' :class='item[0] === $route.path && "is-active"' @click='change(index + 1)') {{item[1]}}

Find more questions by tags Vue.js