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

249
Visualizações
Vue how to set the active tab

I have a Vue tab component that console logs out the correct index of the selected tab but I don't know how to set the active tab so it is opened. Any help or direction would be appreciated.

Component:

<Tabs
  :tabs="tabs"
  :active-tab-index="activeTab"
  @tab-changed="changeTab"
/>

Markup

<div v-show="activeTab === 0">
Show tab one content
</div>

<div v-show="activeTab === 1">
Show tab two content
</div>

Data:

  data() {
    return {
      tabs: [
        { id: 0, name: 'Tab One' },
        { id: 1, name: 'Tab Two' },
      ],
      activeTab: 0,
    }
  },

Method:

changeTab(index) {
  console.log('Change activeTab', index)
},
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

it's not completely clear to me where the method and data is, but I assume it's in the parent, so in that case you'd simply need to change the function to something like this:

changeTab(index) {
  this.activeTab = index
},

your component could be even cleaner if it would provide option to use v-model on it like: v-model:activeTabIndex="activeTab". To make this happen you'd just need to emit the data inside the component with update:activeTabIndex instead of tab-changed.

about 4 years ago · Juan Pablo Isaza Relatório
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