常用方式
这是最常见的方式,也是我之前经常用的。
var Color = {
Red: 0,
0: 'Red',
Green: 1,
1: 'Green',
Blue: 2,
2: 'Blue'
}
TypeScript编译出的枚举代码
var Color;
(function (Color) {
Color[Color["Red"] = 0] = "Red";
Color[Color["Green"] = 1] = "Green";
Color[Color["Blue"] = 2] = "Blue";
})(Color || (Color = {}));