Answer the question
In order to leave comments, you need to log in
Is it possible to check the props of an object in vue?
Hello.
Vue props have a great ability to validate input parameters such as required, type, validation and so on.
Is it possible to set such parameters for object keys?
Conditionally if I pass an object to a component.
And in props I process something like
normal props
props: {
title: String,
likes: Number,
isPublished: Boolean,
}
props: {
data:{
title: {
required:true
},
label: {
required:true
}
}
}
Answer the question
In order to leave comments, you need to log in
Probably possible.
props: {
data: {
type: Object,
required: true,
default: () => { return {} },
}
}
For View props, it is possible to create your own validator function. In theory, what interests you is described in this section:
https://ru.vuejs.org/v2/guide/components-props.htm...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question