vuejs-challenges icon indicating copy to clipboard operation
vuejs-challenges copied to clipboard

323 - Prop Validation

Open devzom opened this issue 3 years ago • 0 comments

<script lang="ts" setup>
import { PropType } from 'vue';

type ButtonType = 'primary' | 'ghost' | 'dashed' | 'text' | 'default';

const props = defineProps({
  type: {
    type: String as PropType<ButtonType>,
    default: 'default',
    validator: (value) => {
      return ['primary', 'ghost', 'dashed', 'text', 'default'].includes(value);
    },
  },
});
</script>

<template>
  <button :type="props.type">Button</button>
</template>

devzom avatar Sep 21 '22 07:09 devzom