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

165
Views
hacer la casilla de verificación de una sola opción

¡Quiero aplicar este código en vuejs, reemplacé onclick por @click pero no funciona! pd: soy principiante en vuejs

 function onlyOne(checkbox) { var checkboxes = document.getElementsByName('check') checkboxes.forEach((item) => { if (item !== checkbox) item.checked = false }) } <input type="checkbox" name="check" onclick="onlyOne(this)"> <input type="checkbox" name="check" onclick="onlyOne(this)"> <input type="checkbox" name="check" onclick="onlyOne(this)"> <input type="checkbox" name="check" onclick="onlyOne(this)">
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Un enfoque básico a la pregunta que usted declaró:

 new Vue({ el: "#app", data() { return { checkboxes: [{ checked: false }, { checked: false }, { checked: false }, { checked: false }, ] } }, methods: { onChange(cb) { this.checkboxes = this.checkboxes.map(checkbox => ({ checked: cb == checkbox })) }, }, template: ` <div> <div v-for="(checkbox, i) in checkboxes" :key="i" > <input type="checkbox" :checked="checkbox.checked" @change="() => onChange(checkbox)" /> {{ checkbox.checked }} </div> </div> ` })
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"></div>

about 4 years ago · Juan Pablo Isaza 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!