Skip to content
Advertisement

VueJs 3 – Custom Input Component

I’m trying to build a custom HTML <input> component for VueJS3. I’ve been following this tutorial:

https://dev.to/viniciuskneves/vue-custom-input-bk8

So far I managed to get the CustomInput.vue component to work and emit the modified value back to the parent App.Vue.

JavaScript

What I don’t understand is – how will the emitted events be detected by the parent App.vue component? I can’t see it happens, and I can’t find it in the tutorial.

My App.Vue looks like this:

JavaScript

Thanks in advance for any help 🙂

Advertisement

Answer

This tutorial is for Vue 2 – for Vue 3 there is another tutorial (https://www.webmound.com/use-v-model-custom-components-vue-3/)

Emitting input event works in Vue 2 only – for Vue 3 you will have to emit update:modelValue and also use modelValue as a prop instead of just value.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement