我正在使用 Nuxt 3 / Vue 3 defineProps 和 TypeScript,并希望从 TypeScript 类型推断 types prop 类型。
import { User } from '~/types/types'
const props = defineProps({
users: {
type: Array, // User[]?
},
})
在此示例中,如何使 users 属性成为 User[] 类型?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
使用Vue的
PropTypeimport { PropType } from 'vue' import { User } from '~/types/types' const props = defineProps = ({ users: { type: Array as PropType<User[]> }, })