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

90
Vistas
Toggle data in vue

I want to display data for each record by language(so more languages will be there, there will be more tabs for each record),

So I made a simple method, if the value equals key and index it should display the required tab.

I have following markup in template:

        <div
          class="nav-item"
          v-for="(property, keyProp) in item.props"
          :key="keyProp"
        >
          <ul class="nav nav-tabs nav-line-tabs mb-5 fs-6">
            <li class="nav-item" v-for="(language, key) in property" :key="key">
              <a
                class="nav-link"
                data-bs-toggle="tab"
                @click="toggle(key + keyProp)"
              >
                {{ key }}
              </a>
            </li>
          </ul>
          <div
            v-for="(language, key) in property"
            :key="key"
            v-show="isOpenIndex === key + keyProp"
          >
            {{ key + keyProp }}
            <input
              type="text"
              v-model="language.text"
              class="form-control form-control-solid"
            />
          </div>
        </div>

And method:

  methods: {
    toggle: function (index) {
      this.isOpenIndex = index;
    },

But for some reason it doesn't work in this way. I can make it work like if I add to data something like isOpenIndex: this.IsOpenIndex but it will display only one tab in a time, closing others if I press another. How to prevent that?

I only want to close the previously opened tab if it's the same record only.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

So I come up with this, slightly modified method function and everything works.

    toggle: function (id, lang, type) {
      for(var key in this.item.props[id][lang]) {
         var prop = this.item.props[id][lang][key];
         if(prop.active === true) {
           return [ prop.active = false, this.item.props[id][lang][type].active = true ]
         }
      }
      return this.item.props[id][lang][type].active = true   
    },

I've added to each value active: false, so by default all hidden. Though when method gets run, it replaces false to true, if true already set it goes though if statement inside loop and drop old parameter to false and replace new one with true

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