To emit a function call to the parent element in a Vue.js FormKit custom input with TypeScript, you can use the this.$emit()
method within the method of the custom input component. The this.$emit()
method takes two arguments: the event name and the argument(s) to be passed to the parent.
Here's an example implementation:
index.ts524 chars27 lines
In this example, the updateValue()
method is called whenever the input changes. Within updateValue()
, we first call the onChange()
function provided by FormKit to update the input value. Then, we use this.$emit()
to emit the parentFunc
event with the value
argument passed as its parameter. We can listen for this event in the parent component and perform the desired function call.
gistlibby LogSnag