How does vue achieve navigation highlighting?

clipboard.png

as shown in the figure, when you jump to a component, the corresponding left navigation turns red.
the class that controls highlighting is as follows:

.active{
    backgournd-color:yellow;
}

how to achieve it? there is no train of thought at all.

Mar.10,2021

vue-router you can set activeClass , linkActiveClass configure


to get the navigation index, save it, judge whether it is the current navigation according to the index, if yes, add your class


vuex, a global currentNav


official document has, very simple, activeClass

Menu