Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

284
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda