props 传参为 object 时,怎么对子属性进行检验啊? #12582
Unanswered
elarbor
asked this question in
Help/Questions
Replies: 1 comment
-
可以吧这两个参数单独传递过来,在进行后续操作⬇️ defineProps({
moduleCode: {
type: String,
required: true
},
itemId: {
type: String,
required: true
},
}) 也可以使用自定义校验函数,不过需要vue 3.4+ defineProps({
params:{
type:Object,
validator(value, props) {
return value.moduleCode && value.itemId
}
}
}) 具体可看 Props校验规则 https://vuejs.org/guide/components/props.html#prop-validation |
Beta Was this translation helpful? Give feedback.
0 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
比如我想校验这两个字段必传
Beta Was this translation helpful? Give feedback.
All reactions