You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
418 B

// 泛型工具类型:Partial<Type> 用来构造(创建)一个类型,将 Type 的所有属性设置为可选
interface Props {
id: string
children: number[]
}
// 使用 泛型工具 Partial
type PartialProps = Partial<Props>
// 没有用泛型工具,属性是必加的
let p1: Props = {
id: '',
children: [1]
}
// 加入 PartialProps 后,属性可加可不加
let p2: PartialProps = {}