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

191
Views
Acceder a la altura de un div en la aplicación Nuxt arroja un mensaje de error

Estoy tratando de acceder a la altura de un div en una cuadrícula en una aplicación Nuxt.

 <template> <div class="grid grid-cols-3"> <client-only> <Item v-for="( item, itemIndex ) in ItemsArray" :key="`item-${itemIndex}`" v-bind="item" :ref="`item${itemIndex}`" /> </client-only> </div> </template> <script> export default { mounted() { this.itemHeight = this.$refs.item1.clientHeight }, data() { return { itemHeight: 0, } } } </script>

Pero recibo este mensaje de error Cannot read properties of undefined (reading 'clientHeight') . no se como arreglar eso...

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

0

Esto se debe a que cuando agrega una ref en un v-for Vue, se creará una matriz de refs y no cada ref en sí.

Actualmente no estoy en mi PC, pero por lo que recuerdo, tendrás que hacer algo como:

 mounted() { this.itemHeight = this.$refs.item1[0].clientHeight },

Si esa no es la respuesta, intente depurar con console.log(this.$refs.item1) para ver exactamente cómo está estructurado. A partir de ahí podrás descubrirte a ti mismo.

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!