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.
 
 
 
 
 

16 lines
400 B

// 泛型工具类型:Record<Keys, type> 构造一个对象类型,属性键为 Keys, 属性类型为 Type
type RecordObj = Record< 'a' | 'b' | 'c', string[]> // 表示属性键 a、b、c 都是 string 类型的数组
let obj: RecordObj = {
a: ['a'],
b: ['b'],
c: ['c']
}
// 不使用工具类型 Record
type RecordObj2 = {
a2: string[]
b2: string[]
c2: string[]
}