Last active
March 8, 2023 12:58
-
-
Save jbjorge/64a5457a76f3a8142bf692b09aebc4dc to your computer and use it in GitHub Desktop.
Old style vue props
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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