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

154
Views
Vue2 obtiene el ancho del tramo y da clase en función de ese ancho

tengo este li:

 <li v-for="(row, index) in onceItems" :key="row.product.ID"> <span class="title" ref="title" :class="{ max: getTitleWidth(index) > 200 }"> {{row.product.post_title}} </span> </li>

Quiero darle a la clase "máximo" si el elemento está por encima de 200 px (detectar títulos largos)

 methods: { getTitleWidth: function(index) { this.$nextTick(() => { let width = this.$refs.title[index].clientWidth; console.log(width); return width }) }, }

El registro de la consola devuelve el valor correcto, pero no se proporciona la clase. Creo que tiene algo que ver con nextTick, pero sin él obtengo un valor indefinido.

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