`withDefaults` in dev mode, appears props warn
Vue version
latest
Link to minimal reproduction
Steps to reproduce
use withDefaults
What is expected?
disabled this warning
What is actually happening?
I knew that withDefaults
will set a default value in runtime, but it still appear a warning
System Info
No response
Any additional comments?
No response
This is as expected
withDefaults(defineProps<{
age: number
}>(), {
age: 1
})
Equivalent to
export default {
props: {
age: {
type: Number,
required: true,
default: 1
}
}
}
When a props is required to be passed in, it means that it needs to be passed to the component anyway, whether it has a default value or not