Skip to content

Instantly share code, notes, and snippets.

@jbjorge
Last active March 8, 2023 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbjorge/64a5457a76f3a8142bf692b09aebc4dc to your computer and use it in GitHub Desktop.
Save jbjorge/64a5457a76f3a8142bf692b09aebc4dc to your computer and use it in GitHub Desktop.
Old style vue props
<script setup lang="ts">
// inferred type from `String`
const props = defineProps({
foo: String
})
// specific type
const props = defineProps({
foo: String as PropType<'foo' | 'bar'>
})
// with defaults
const props = defineProps({
foo: {
type: String as PropType<'foo' | 'bar'>,
default: 'bar'
}
})
// required
const props = defineProps({
foo: {
type: String as PropType<'foo' | 'bar'>,
required: true
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment