Issue
How to get rid of the TS warning in Vue template?
I'm using the example provided in Vue 3 manual
<input
type="text"
:value="title"
@input="$emit('update:title', $event.target.value)"
>
Note: This only an TS warning, this works as it should.
Solution
My solution with help of Mic Fung. Create an handler method...
import { defineEmits } from 'vue'
const emit = defineEmits(['update:value'])
const updateValue = (e: Event) => {
emit('update:title', (e.target as HTMLInputElement).value)
};
<input
:value="value"
type="text"
@input="updateValue"
/>
My option on the root of the problem: https://github.com/vuejs/jsx-next/issues/234
Answered By - sainf
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.