Saya menggunakan Nuxt 3 / Vue 3 defineProps
dan TypeScript dan ingin membuat kesimpulan jenis prop daripada jenis TypeScript.
import { User } from '~/types/types' const props = defineProps({ users: { type: Array, // User[]? }, })
Bagaimana untuk membuat users
屬性成為 User[]
taip contoh ini?
Menggunakan VuePropType
import { PropType } from 'vue' import { User } from '~/types/types' const props = defineProps = ({ users: { type: Array as PropType<User[]> }, })