如何在TypeScript中迭代一个集合?对于当然不起作用:
'Set<string>' is not an array type or a string type
.forEach
是不可接受的,因为它隐藏了this
.我不想在try-catch区块中做一个while循环.我错过了什么?它不可能如此笨拙,以至于需要try {while}捕捉{}.
如何在TypeScript中迭代一个集合?对于当然不起作用:
'Set<string>' is not an array type or a string type
.forEach
是不可接受的,因为它隐藏了this
.我不想在try-catch区块中做一个while循环.我错过了什么?它不可能如此笨拙,以至于需要try {while}捕捉{}.
@SnareChops基本上是正确的:
mySet.forEach(function(item){
// do something with "this"
}, **this**);
这很管用.
我猜:
for(item of mySet.values()){
}
如果我没有把一切都搞糟的话.但是垫片material 是由Angular 2 crew指定的,所以_(ツ)_/¯
唯一有效的另一件事是:
for (var item of Array.from(set.values())) {
}
或者类似的事情,这太可怕了.