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

150
Views
¿Por qué this.$refs.inuputField'.focus() no funciona en Vue?

He creado un campo de entrada y le he dado un ref="inputField" así

 <input ref="inputField"> <button @click="btn">Click</button>

Al hacer clic, quiero agregarle enfoque y he escrito el código de esta manera

 <script> methods:{ btn(){ this.$refs.inputField.focus() } } </script>

Pero esto no funciona. ¿Alguien puede explicar cómo hacer una entrada en el foco cuando se hace clic en el botón? Lo quiero cuando se hace clic en el botón.

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

0

Tu código funciona. Vea este ejemplo .

Sin embargo, al menos necesita export default :

 <script> export default { methods: { btn() { this.$refs.inputField.focus() } } } </script>
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!