[Vuejs]-Accessing height of a div in Nuxt application throws error message

0👍

That’s because when you add ref in a v-for Vue will be creating an array of refs and not each ref itself.

I’m not currently on my PC but from what I remember you will have to do something like:

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

If that’s not the answer, try to debug with console.log(this.$refs.item1) to see exactly how it is structured. From there you will be able to figure out yourself

Leave a comment