Home > front end >  Vue Router resets my component when I route to another component
Vue Router resets my component when I route to another component

Time:11-24

Whenever I route between two views, the first view components are all reset! is there a way to keep the states of the first view without reset while routing? thanks in advance.

<div>
  <div id="titleControl">
    <router-link :to="{ name: 'controls' }" >
      Controls
    </router-link>
    <router-link :to="{ name: 'logs' }" >
      Logs
    </router-link>
  </div>

  <router-view />
</div>

CodePudding user response:

One solution for this is wrapping the <router-view> inside the <KeepAlive> component.

  • Related