I'm trying to replace my Vue 2 options API props object code with Vue 3 script setup syntax in TypeScript.
Existing:
type: {
type: String,
default: 'button',
validator: (prop) => ['button', 'submit', 'reset'].includes(prop)
}
I have this so far:
<script lang="ts" setup>
interface Props {
type?: string;
}
const props = withDefaults(defineProps<Props>(), { type: 'button' });
</script>
But I can't find any info on how to handle prop validators in the script setup syntax.
validators
to work? None of the answers is working for me in March 2023 – Caban