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

131
Vistas
matriz de bucle con objeto tenemos diferentes tipos dentro de un componente

hola, no quiero hacer un bucle de matriz con objetos que tenemos diferentes tipos dentro de un componente

 operations = [ { "id": 15525205, "type": "mise_en_prep", "referenceMep": "MB0153", "tax": 20, "size": "M" } { "id": 16525205, "type": "invoice", "referenceInvoice": "MB0153", "tax": 20, "size": "M" } ] <div v-for="item in operations"> <my-component :size="item.size" // if type is mise_en_prep :tax="item.tax" // if type is invoice :invoice="item.referenceInvoice" // if type is invoice </my-component> </div>

mi problema es que quiero hacer un bucle en esta matriz con diferentes tipos de objetos en un componente. por favor gracias

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

0

Puedes probar con v-if :

 Vue.component('MyComponent', { template: ` <div class=""> {{ size || tax }} </div> `, props: ['size', 'tax', 'invoice'] }) new Vue({ el: '#demo', data() { return { operations: [ {"id": 15525205, "type": "mise_en_prep", "referenceMep": "MB0153", "tax": 20, "size": "M"}, {"id": 16525205, "type": "invoice", "referenceInvoice": "MB0153", "tax": 20, "size": "M"}, {"id": 17525205, "type": "invoice", "referenceInvoice": "MB0153", "tax": 20, "size": "M"}, {"id": 18525205, "type": "mise_en_prep", "referenceInvoice": "MB0153", "tax": 20, "size": "M"} ] } } }) Vue.config.productionTip = false Vue.config.devtools = false
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="demo"> <div v-for="(item, i) in operations" :key="i"> <my-component v-if="item.type === 'mise_en_prep'" :size="item.size" :tax="''" :invoice="''"> </my-component> <my-component v-if="item.type === 'invoice'" :size="''" :tax="item.tax" :invoice="item.referenceInvoice"> </my-component> </div> </div>

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