To emit a function call to the parent element in a Vue.js Formkit custom input using Composition API and Typescript API in Typescript, you can use the emits
option to define the event that should be emitted from the child component.
Here's an example of how you can achieve this:
index.ts649 chars35 lines
In the example above, we define the onCustomEvent
prop, which accepts a callback function that should be called when the custom event is emitted from the child component. We also define the emits
option to specify that the customEvent
event should be emitted from the child component.
In the setup()
function, we define a handleClick()
function that emits the customEvent
event and passes some data as an argument. When the handleClick()
function is called, it will emit the customEvent
event with the data provided.
Finally, in the parent component, you can pass a callback function to the onCustomEvent
prop to handle the emitted event:
index.ts506 chars28 lines
In the parent component, we define a handleCustomEvent()
method that will be called when the customEvent
event is emitted from the child component.
gistlibby LogSnag