前端工程师666777888
interface Info { col1: string; // 假设第一列是字符串类型 col2: number; col3: boolean; //... 依次声明其他17列的类型 col20: string; }
type ColumnType = string | number | boolean; // 定义一个联合类型,表示列可能的类型
interface Info {
[key: string]: ColumnType; // 使用索引签名,表示Info接口可以有任意字符串键,值为ColumnType类型
}
样既保证了类型的准确性和安全性,又在一定程度上简化了代码的书写