【发布时间】:2021-08-24 12:04:51
【问题描述】:
我在.ts 扩展名的单独文件中创建了下面发布的颜色枚举。我想知道如何在发布的代码中使用或调用for-loop 中的枚举,以便能够迭代抛出它。
换句话说,如何在循环中遍历下面发布的枚举,以便设置ì = 0 RED 以及何时设置i=7 LIME。
显然,双问市场将被替换为通过枚举的迭代。
代码:
for(let i = 0; i < centerPointsClusters.length;i++) {
this.centerPoint = this.APIService.visualisePoint(this.map,centerPointsClusters[i], ??)
}
枚举:
export enum ColorEnum {
RED = "#F44336",
PINK = "#FF4081",
PURPLE = "#9C27B0",
INDIGO = "#536DFE",
BLUE = "#2196F3",
TEAL = "#64FFDA",
GREEN = "#4CAF50",
LIME = "#EEFF41",
YELLOW = "#FFEB3B",
ORANGE = "#FFAB40"
}
【问题讨论】:
-
@R.Richards 不,它没有。我想根据循环中 i 的索引遍历枚举
标签: javascript angular