【发布时间】:2021-04-12 02:49:16
【问题描述】:
我正在使用 typescript Nodejs(MEAN 堆栈)
尝试在 json 的属性/模式中使用 enum
一个示例枚举就像
Enum KeyEnums {
A: "featureA",
B: "featureB",
C: "featureC"
}
预期的 JSON
{
featureA: "This is feature A",
featureB: "This is feature C",
featureC: "This is feature C"
}
我想要达到的方式
{
KeyEnums.A: "This is feature A",
KeyEnums.B: "This is feature C",
KeyEnums.C: "This is feature C"
}
但是,得到一个错误提示
"Property or signature expected"
..无论如何要在 JSON 属性的地方实现枚举的使用?
【问题讨论】:
-
@Anatoly 完全正确.. 非常感谢!!!
-
@Anatoly 如果您将其添加到 cmets,我将接受并完成此问题线程!
标签: node.js json typescript express enums