-
Notifications
You must be signed in to change notification settings - Fork 541
Open
Description
Currently we can set default values like so:
export default {
name: 'Knight',
props: {
name: {
type: String,
},
isKnight: {
type: Boolean,
default: false,
},
},
}
In this example we'd have to pass if a person is a knight or not:
<Knight name="John" is-knight="false" />
However, very often I need to look at other props and calculate a props' default state based on these other props.
A nice addition to default values for props could be:
export default {
name: 'Knight',
props: {
name: {
type: String,
},
isKnight: {
type: Boolean,
default: props => props.name.includes('Sir'),
},
},
}
reed-jones, SnosMe, byrdkm17 and thedamonfnlctrl, cawa-93, Meekohi, ellepereira, Leokuma and 1 more
Metadata
Metadata
Assignees
Labels
No labels