报错信息
Vue3.3中新增了一些特性,其中包括更符合人体工学的一些写法
如下图:
可是当我在项目中尝试的时候,却报错:
解决方案
这个报错,具体原因似乎是来自TS的限制
可以使用如下方法解决
方法一:
type EmitProps = Omit<
{
change: [v: any]
},
''
>
const emits = defineEmits<EmitProps>()
方法二:
type EmitProps = {
change: [v: string]
}
const emits = defineEmits<EmitProps>()
这么写就不会报错啦,具体参考的这个链接:github.com
如有错误,可在评论区指出,感谢🙏