一、场景:中括号读取对象中值的时候报错:【类型“String”不能作为索引类型使用】、切换成any 之后【元素隐式具有 “any” 类型,因为类型为 “any” 的表达式不能用于索引类型 “attr_type”。】 二、查阅资料 有说在tsconfig中配置suppressImplicitAnyIndexErrors-true的【亲测无效】、 最后通过 keyof typeof 完美解决。 三、解决办法 使用 keyof typeof