1
Hello, I have a component that should receive two props, one that indicates if this component needs a date and a date that should be passed if and only if the component needs a date. Thus, the component should play an Exception if the prop needsDate is passed as true and no date is passed. thought of the following code:
props: {
needsDate: {
type: Boolean,
default: false
},
date: {
type: String,
required: this.needsDate
}
}
The problem is that this form does not generate the expected behavior, when step needsDate=true without passing date the component renders date as Undefined instead of throwing an error. Could someone help me understand why this happens and/or what the right way to do it?