Vue2 solves the problem that the navigation bar style active is disordered when the page is refreshed

The router.js route shows:

insert image description here

html:

Correspond a field in the loop to a field in the route. What I directly choose here is the address path.

Set: class="{active:$route.path === item.menuUrl}"

You can control the navigation active style without setting the click event on the li tag; whether it is a button jump in the page or a page refresh, the active style will never fail.
insert image description here

Guess you like

Origin blog.csdn.net/Maybe_ss/article/details/122251999