error typescript使用场景:用变量作为object的key取值,语法报错 typeof ‘string’ can not be used index type solution 指定object的key的类型即可 obj: { [k:string]: string } 报错代码: 正常代码: