Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

286
Views
¿Cómo vincular en V el atributo de identificación del botón usando Vuejs?

Estoy seguro de que hay una manera de hacerlo, pero no puedo entender por qué no funciona para mí (soy completamente nuevo en vuejs)

Intenté usar la etiqueta del botón:

 <div v-for="line in lines"> <button v-bind:id="line.id" name="availabilityCheck" type="button"> Check availability </button> </div>

Y la entrada de tipo de botón:

 <div v-for="line in lines"> <input v-bind:id="line.id" name="availabilityCheck" type="button" value="Check availability" /> </div>

Lo que sucede es que el navegador elimina la parte v-bind:id="line.id" por lo que básicamente los botones generados no tienen una identificación.

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

No estoy seguro de por qué no funciona para usted, pero idealmente debería funcionar si su matriz de líneas contiene la propiedad de identificación en los objetos.

demostración:

 new Vue({ el: '#app', data: { lines: [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }] } })
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"> <div v-for="line in lines" :key="line.id"> <input v-bind:id="line.id" name="availabilityCheck" type="button" value="Check availability" /> </div> </div>

Captura de pantalla :

ingrese la descripción de la imagen aquí

about 4 years ago · Santiago Trujillo Report

0

<div v-for="line in lines"> <button :id="'lin'+line.id" name="availabilityCheck" type="button"> Check availability </button> </div>

Agregar una constante en el prefijo puede funcionar

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!