我正在处理下拉菜单列表。
this[dropdownName] = Object.entries(value).map(a => {
console.log(a);
return a[1].prvid + ' - '+ a[0];
})在控制台上使用上面的代码,我会得到如下结果
[0: "xyz"
1: {prvid: 11}]我需要返回一个带有的1.prvid concat。
但我收到的typescript错误如下:
[ts] Property 'prvid' does not exist on type '{}'.发布于 2019-03-07 16:36:28
显然,TypeScript type inference无法弄清楚a[1]是什么类型,或者更确切地说,它认为它是什么类型,但它认为它是{} (没有prvid属性)。您需要添加必要的type annotations来告诉TypeScript a[1]是什么类型(可能是通过告诉它a是什么)。
https://stackoverflow.com/questions/55039261
复制相似问题