【发布时间】:2018-11-09 17:41:52
【问题描述】:
我在打字稿中有一个枚举。我需要将枚举的值转换为字符串,以便可以将其传递给 api 端点。我该怎么做呢?谢谢。
enum RecordStatus {
CancelledClosed = 102830004,
Completed = 102830003,
InProgress = 102830002,
ShoppingCart = 102830005,
Submitted = 102830001,
Unordered = 102830000
}
示例:
var submittedStrValue = RecordStatus.Submitted // I want to get "10283001" (note the string value rather than the int value.
【问题讨论】:
-
那么,您是在问如何将数字转换为字符串?
-
好的,我认为这需要像 RecordStatus[RecordStatus.Submitted] 这样的操作。
-
@JeffreyJuarez 如果你想得到字符串
Submitted。见typescriptlang.org/play/…
标签: typescript