类型推论
1.定义字段imgs是由ImgsData类型组成的数组
2.定义字段imgobj是由ImgsData类型组成的对象
import { PropType } from 'vue'
import { ImgsData } from '@/interface'
export default defineComponent({
props: {
imgs: {
type: Array as PropType<ImgsData[]>,
default: () => []
},
imgobj: {
type: Object as PropType<ImgsData>,
default: () => []
},
},
})
interface.ts
export interface ImgsData {
attachmentName: string
attachmentOrder: number
attachmentUrl: string
}