]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
chore: defining default values for Props using withDefaults (#1880)
author丶远方 <yangpanteng@gmail.com>
Tue, 13 Feb 2024 15:50:28 +0000 (23:50 +0800)
committerGitHub <noreply@github.com>
Tue, 13 Feb 2024 15:50:28 +0000 (16:50 +0100)
[skip ci]

packages/docs/.vitepress/theme/components/HomeSponsorsGroup.vue

index 8e876c6f679ff8ac74261ef8ea3e75dc25cff2e2..3ec29135fa2b6486e70f40033a1b826c282670d4 100644 (file)
 <script setup lang="ts">
 import sponsors from './sponsors.json'
 import { computed } from 'vue'
-import type { PropType } from 'vue'
 import { useData } from 'vitepress'
 
-const { isDark } = useData()
+interface Props {
+  name: 'Gold' | 'Platinum' | 'Silver' | 'Bronze'
+  size?: number | string
+}
 
-const props = defineProps({
-  name: {
-    type: String as PropType<'Gold' | 'Platinum' | 'Silver' | 'Bronze'>,
-    required: true,
-  },
-  size: {
-    type: [Number, String],
-    default: 140,
-  },
+const props = withDefaults(defineProps<Props>(), {
+  size: 140,
 })
 
+const { isDark } = useData()
+
 const list = computed(() =>
   sponsors[props.name.toLowerCase()].map((sponsor) => ({
     ...sponsor,