我有这段代码:
const sectionInstance: FieldValues = sectionInstances[i]
for (const field in sectionInstance) {
console.log(sectionInstance[field])
}
field这里当然是一个字符串。这是 的类型定义FieldValues:
export interface FieldValues = {
[key: string]: FieldValue;
}
我仍然收到此错误:
元素隐式具有“任何”类型,因为类型“字符串”的表达式不能用于索引类型“FieldValues”。在类型“FieldValues”上找不到参数类型为“string”的索引签名。Vetur(7053)
我没有为 声明类型为“string”的索引签名interface FieldValues吗?为什么会出现此错误?
Qyouu
不负相思意
相关分类