A
A
Alexey Chernyshov2018-12-24 11:32:33
JavaScript
Alexey Chernyshov, 2018-12-24 11:32:33

How to bind event handling for VNode ( vuejs )?

How to bind processing to an event from a slot, the example outlined below.
For some reason, this.$slots.default[0].elm outputs undefined while walking in the console this.$slots.default[0] outputs the VNode object of the html
file:

<vue-input>
   <input type="text" />
</vue-input>

vuejs file
export default {
   name: 'VueInput',
    created () {
        this.$slots.default[0]. ????
   }
}

How to add event handling to the click example?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-12-24
@WebDiamis

How to bind processing to an event from a slot

It is not very clear why this is necessary.
Because there is no element yet, in order for it to appear, you have to wait for the component instance to be mounted in the DOM - if you use mounted instead of created, you will see that the element is there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question