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

83
Vistas
For loop in vuejs like php

It is possible in vuejs to v-for a loop like php?

I want this output:

<select>
    <option>2</option>
    <option>1</option>
    <option>0</option>
</select>

My code (ticket.quantity = 2):

<select>
    <option v-for="index in ticket.quantity" :value="index" :key="index">{{index}}</option>
</select>

My output:

<select>
    <option>2</option>
</select>
about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

You can try to loop ticket.quantity + 1 :

new Vue({
  el: '#demo',
  data() {
    return {
      ticket: {quantity: 2}
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <select>
    <option v-for="(q, index) in ticket.quantity + 1" :value="index" :key="index">{{index}}</option>
  </select>
</div>

about 4 years ago · Santiago Gelvez Denunciar

0

The answer of Nikola didn't worked for me completely but I managed to solve it like this:

<select>
    <option value="0" selected>0</option>
    <option v-for="index in parseInt(ticket.quantity)" :value="index" :key="index">{{index}}</option>
</select>
about 4 years ago · Santiago Gelvez 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