Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

285
Vistas
How to save the opened tab state in vue.js? (script setup)

How can i save the state of opened tab while refreshing? I have two tabs If I opened 2nd tab and than i refresh, it took me back to 1st tab. My code is

<template>
  <section>
    <div>
      <button
        @click="changeTab(CandiComTab1)"
        class="uppercase px-3 w-auto py-3 text-xs"
      >
        timeline
      </button>
      <button
        @click="changeTab(CandiComTab2)"
        class="uppercase px-3 w-auto mx-1 text-xs py-3"
      >
        community member list
      </button>
    </div>
    <div>
      <keep-alive>
        <component :is="currentTabComponent"></component>
      </keep-alive>
    </div>
  </section>
</template>

<script setup>
import { markRaw, ref } from "@vue/reactivity";
import { useStore } from "../../store";
import CandiComTab1 from "./CandiCommunityTabs/CandiComTab1.vue";
import CandiComTab2 from "./CandiCommunityTabs/CandiComTab2.vue";
const store = useStore();
let currentTabComponent = ref(null);
let changeTab = (newTab) => {
  currentTabComponent.value = markRaw(newTab);
};
changeTab(CandiComTab1);
</script>

I want my browser to remember that which tab was opened before refreshing the page.Suppose I have 3 tabs on 1 page and I opened the 2nd or 3rd tab, than I refresh the page it kick me back to 1st tab. How to prevent this.Is their any solution ?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda