Props
在使用 <script setup> 的单文件组件中,props 可以使用 defineProps() 宏来声明:
vue
<script setup>
const props = defineProps(['foo'])
console.log(props.foo)
</script>如果你正在搭配 TypeScript 使用 <script setup>,也可以使用类型标注来声明 props:
vue
<script setup lang="ts">
defineProps<{
title?: string
likes?: number
}>()
</script>