我在typscript中有一个枚举。我需要将枚举的值转换为字符串,以便我可以将其传递给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.
答案 0 :(得分:5)
您可以使用RecordStatus.Submitted.toString()
。