如何验证道具? (VUE3,Coption-API,打字稿)
如何在打字条中使用验证器用于props值?
type Props = {
name: string
type?: string // how to use "validator" ?
modelValue: any
}
const props = defineProps<Props>()
如何使其正如以下声明一样工作:
defineProps({
type: {
type: String,
validator(value) {
return ...
}
}
})
How to use validator for props value in typescript?
type Props = {
name: string
type?: string // how to use "validator" ?
modelValue: any
}
const props = defineProps<Props>()
How to make it work as in the following declaration:
defineProps({
type: {
type: String,
validator(value) {
return ...
}
}
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许此堆栈溢出答案会帮助您:
但是通常,在这样的情况下,我只是去官方Vue Discord Server 从Vue Core团队那里获得最佳答案
maybe this stack overflow answer would help you:
but usually, in cases like this, I just go to the official Vue Discord server and ask my questions there to get the best answer from the Vue core team