我有以下枚举,并尝试对其进行迭代:
export enum Values {
name = 'true',
fullName = 'true',
lastName = true,
}
// This is how I am trying to iterate over it
for (let item in Values) {
// Here, if I use console.log(item), I get name as string,
// so how should I access its value in enum?
}
答案 0 :(得分:0)
您必须这样做:
enum Values {
name = 'true',
fullName = 'true',
lastName = 'true',
}
for (let item in Values) {
console.log(Values[item]);
}
输出为:
true
true
true