T
T
thehighhomie2019-09-23 13:15:58
Vue.js
thehighhomie, 2019-09-23 13:15:58

VueJS: Can't get elm from vnode in render function?

Guys, please tell me why it is impossible to get elm from vnode in the render function? can i solve it somehow?

render (h) {
    this.$slots.default.forEach(vnode => {
      console.log(vnode.elm) // undefined
    })

    return h('div', {
      class: 'v-box'
    }, this.$slots.default)
  }

Maybe I just missed something. I'm trying to write a specific image grid, for this I need the sizes of all the images (in this case, the slots) and having obtained the sizes, calculate everything that is needed.
But due to the fact that I can not get the element, nothing happens.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grinat, 2019-09-23
@thehighhomie

Because they don't exist, the data will be there after the data is rendered https://vuejs.org/v2/guide/instance.html#Lifecycle...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question