数字为键命名
const data :{[key: number]: string} = {
1: 'a',
2: 'b'
}
当后端返回的对象键不确定的时候
const data :{[key: string]: string} = {
'xxx': 'a',
'abc': 'b'
}
常用类型
export type StringType = NonNullable<string | null | undefined>;
export type NumberType = NonNullable<number | null | undefined>;
export type BooleanType = NonNullable<boolean | null | undefined>;
export type StringNumberType = NonNullable<string | number | null | undefined>;
export type NumberKey<T = any> = { [key: number]: T }
export type StringKey<T = any> = { [key: string]: T }
export type Option = { label: string; value: string }