【发布时间】:2020-04-24 00:44:55
【问题描述】:
大家好,我应该提到我是打字稿的新手。实际上,我有一个地图,其中数字作为键,数字数组作为值。在我的 html 中,我必须显示所有键,并且根据所做的选择,我必须显示值(键和值都显示为 ion-segment-button)。问题是我无法使用trmap.get(key) 获取任何键的值
here is the error i get in console/////////////////
here is the map a par of the json
这是我的 ts 文件:
trmap: Map<number,number[]>
values:number[]
getSelectedKey(key :number) {
console.log(key)
this. values=this.trmap.get(key)
}
【问题讨论】:
-
您能否提供在尝试获取值时遇到的错误等?
-
我做了一个更新,显示控制台中的错误..谢谢你
-
我现在看到了,
get似乎已定义但不是函数。你确定你拥有的确实是Map? -
@alexortizl 绝对正如我所提到的,我已经使用 "*ngFor="let t of trmap | 显示了按钮中的键。 keyvalue”,我需要显示每个选择的键的值
标签: typescript dictionary ionic-framework