Reputation: 4879
I try to define my component props where type is Array
But it not working...
import { Person } from '...'
export default defineComponent({
props: {
people: Array<Person>
}
})
export class Person {
...
}
How to declare it correctly ?
Upvotes: 9
Views: 12907
Reputation: 309
(Vue v3.0.4)
Use PropType:
import { Person } from '...'
import { defineComponent } from 'vue';
import type { PropType } from 'vue'
export default defineComponent({
props: {
people: Array as PropType<Array<Person>>,
default: () => [],
}
})
Ref: https://vuejs.org/api/utility-types.html#proptype-t
Upvotes: 3
Reputation: 141
use Proptype imported from 'vue'
import { Person } from '...'
import { defineComponent, PropType } from 'vue';
export default defineComponent({
props: {
people: Array as PropType<Array<Person>>,
default: undefined,
}
})
Upvotes: 14