originalData: {
type: Array | Object,
default () {
return []
}
}
}
```
查看vue 源码,对于props类型的定义如下:
```typescript
export interface PropOptions<T=any> {
type?: PropType<T>;
required?: boolean;
default?: T | null | undefined | (() => T | null | undefined);
validator?(value: T): boolean;
}
可以看到对于props 对象的定义除了常用的 type参数,还有required,default,validator三个参数,在default参数中,多个类型使用 | 隔开。
升级到vue3写法
originalData: {
type: [Array, Object]
default () {
return []
}
}
}
```