Home > Blockchain >  Vue3 create componentes dynamic
Vue3 create componentes dynamic

Time:10-15

Hello I was testing Vue3, and I came across a situation that I didn't know how to solve for example.

I have an input component that in loop is created with data from an object, all good, but now I want to pass events to it, it is at this point where I don't know how exactly to pass these events to it. how to read this list

i am trying to create input, using a component, from a json.

Example: https://stackblitz.com/edit/vue-sdkmjl?devtoolsheight=33&file=src/App.vue

CodePudding user response:

For a specific event handler, it can be specified explicitly:

<InputBase v-bind="input" v-model:value="values[input.name]" @input="input.events?.input" />

For a map of event handlers, it can be passed to v-on directive:

<InputBase v-bind="input" v-model:value="values[input.name]" v-on="input.events || {}" />
  • Related