Display the corresponding components after the vue project is refreshed

A page has three components that go to different components with different clicks.
the first time you enter the page displays the first component by default. If you enter the second component, click Refresh how to ensure that the page still displays the second component instead of the default. I just want to do it through the is property of the component.

Aug.09,2021

it is not enough for light to pass through the component.
solution:

  1. pass routing parameters. Enter a, add key = an in the route, and enter the bmaine c component in the same way, and decide which component to display by getting the key in the route.
  2. Click the component using localstorage, save the corresponding tag to storage, and decide to display the component by getting the tag in the store (not recommended);

Save the judged state to the global variable


save to the route or to the local storage, any place where the refresh will not disappear


add the judgment to the route, as long as the refresh does not disappear

Menu