tab-route and pages issue when switching tab

  • Hi. I have created a simple app with route tabs. Each route links to a page (pgGeneral and pgCriteria). I have set this up as advised in the guide notes.
    I have encountered an issue when I switch tab: data entered on pgGeneral get removed when going to the next tab criteria. Is this normal behaviour? If not, how would I get to keep my data? by using vuex?

    Below is my setup:
    layout: default.vue

            :glossy="$q.theme === 'mat'"
            :inverted="$q.theme === 'ios'"
              <div slot="subtitle">Running on Quasar v{{ $q.version }}</div>
          <q-route-tab slot="title" name="tab-1" icon="subject" label="Generalities" to="/" exact />
          <q-route-tab slot="title" name="tab-2" icon="fingerprint" label="Inclusion Criteria" to="/criteria" exact />
          <router-view />

    router --> routes.js:

    export default [
        path: '/',
        component: () => import('layouts/default'),
        children: [
          { path: '', component: () => import('pages/pgGeneral') },
          { path: 'criteria', component: () => import('pages/pgCriteria') }
      { // Always leave this as last one
        path: '*',
        component: () => import('pages/404')

    my pgGeneral is:

        <!-- General Information Tab Card -->
        <q-card class="bg-cyan-2 q-ma-xl">
            <q-field label="Title" >
             <q-input v-model="studyTitle" clearable />
    export default {
      data () {
        return {
          studyTitle: ''

  • Whether or not you persist the data in Vuex… you will need to load it (typically in the created method) in the component that the tab loads. It’s no different than if you took the tabs out of the mix and just navigated between the pages. An alternative would be Vue’s dynamic components which can be wrapped in a keep-alive element.

  • Exactly what @genyded said…

  • Thanks @genyded. I am also experimenting with the keep-alive element.

Log in to reply