webfansplz / vuejs-challenges

Collection of Vue.js challenges
https://vuejs-challenges.netlify.app/
MIT License
2.69k stars 188 forks source link

323 - Prop验证 #2704

Open whitevenus opened 3 months ago

whitevenus commented 3 months ago
<script setup lang="ts">
defineProps({
  type: {
    type:  String,
    required: true,
    default: "default",
    validator: (value:string) => {
      return ["primary", "ghost", "dashed", "link", "text", "default"].includes(value)
    }
  }
})
</script>

<template>
  <button>Button</button>
</template>