PropType

在vue3中用来对props的复杂类型进行验证

  1. 从vue中引入PropType
    1
    import { PropType } from 'vue'
  2. 定义复杂类型接口
    1
    2
    3
    4
    export interface IPerson {
    name: string
    age: number
    }
  3. 属性类型验证
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    props: {
    person: {
    type: Object as PropType<IPerson>,
    default: {
    name: 'Zon.',
    age: 100
    }
    }
    },

参考来源:Vue3 + TS PropType类型验证