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

2.7K
Views
Vue2 cómo usar $ refs para apuntar a un elemento y eliminar la clase css

Quiero eliminar la clase css de un elemento cuando se llama a un método. pero quiero hacer esto usando $refs.

modelo:

 <div class="modal" ref="myModal"></div>

método:

 closeDropdown: function() { this.$refs.myModal.$el.removeClass("open"); }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

this.$refs.myModal.classList.remove("open");
over 4 years ago · Santiago Trujillo Report

0

Dos pasos:

  1. const modalElement = this.$refs.myModal; // reference to the DOM element
  2. modalElement.classList.toggle("custom"); // use classList API of DOM element

Referencia de API classList : https://developer.mozilla.org/en-US/docs/Web/API/Element/classList , puede usar esta API para modificar sus clases usando add(), remove(), replace() y alternar() métodos.

También puede consultar este ejemplo de CodeSandbox Vuejs: https://codesandbox.io/s/nervous-wood-s3nhq?file=/src/App.vue:269-481

over 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!