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

254
Views
cambiar el valor de los datos en el componente vue

Estoy comenzando con vue y estoy haciendo una prueba para cambiar un valor cuando se hace clic en un botón, pero no funciona

 <template> <div class="row"> {{ show }} <div class="col-md-4"> <button class="btn btn-primary" @click="change_show">Good</button> </div> <div class="col-md-4"> <button class="btn btn-primary">Bad</button> </div> <div class="col-md-4"> <button class="btn btn-primary">Food</button> </div> </div> </template> <script> export default { name: "buttons", data(){ return{ show: true } }, methods:{ change_show(event){ show = !show; } } } </script> <style scoped> </style>

me sale este error

 Uncaught ReferenceError: show is not defined

¿Cómo puedo acceder a las variables y cambiarlas?

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

0

Ha declarado su variable incorrectamente, debe agregar show (y todas sus variables reactivas) en el retorno:

 data(){ return{ show: true }; },
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!