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

171
Views
Cómo activar Switch cuando cambia la entrada de forma dinámica en Vue js

Bueno, esta pregunta vino después de esta pregunta mía. Cómo deshabilitar el botón si varias entradas de formulario no cambian en Vue.js

Hay Switch en cada forma. Cuando se cambian las entradas de un formulario, el interruptor debe estar ON desde el estado OFF . Lo he hecho poniendo esta línea en el método de watch en cada formulario.

 this.items.forEach( (_, index) => { this.$watch(['items', index].join('.'), {deep: true, handler: (newVal, oldVal) => { this.changed.push(newVal.id) this.items[index].switch = true }}); });

Después de agregar esta línea, this.items[index].switch = true , el Switch se ON desde OFF ; pero si un usuario vuelve a OFF el Switch haciendo clic en el Switch ; el texto ya no cambia. Siempre permanece ON . como arreglar eso?

Demostración de CodePen

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si agrega esta línea para ver cada vez que cambia este modelo, el interruptor se establece en verdadero. Necesitas un condicional, prueba esto.

 this.items[index].switch = this.changed.includes(newOld.id)
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!