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

250
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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