Skip to content

Instantly share code, notes, and snippets.

@owenconti
Last active January 11, 2021 16:34
Show Gist options
  • Save owenconti/7c62f09d2deb4226b817caa25465466e to your computer and use it in GitHub Desktop.
Save owenconti/7c62f09d2deb4226b817caa25465466e to your computer and use it in GitHub Desktop.
Validating Props in Vue
{
props: {
name: [String, Number]
}
}
{
props: {
person: {
type: Object,
required: true,
validator: value => ['pending', 'in-progress', 'complete'].includes(value)
}
}
}
{
props: {
name: {
type: String,
default: 'Hello'
}
}
}
{
props: {
person: {
type: Object,
default: () => ({
name: 'John'
})
}
}
}
{
props: {
person: {
type: Object,
required: true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment