Looking for way to create a Enum struct with ES2018
有了ES2018,是否有一种更强大的方法来创建这个主题列表(我想要的是自动生成的数字)。
1 2 3 4 5 6 7 8 9 10 11 | const Topics = { NullTopic: 0, simActorStateTest: 1, navActorStateTest: 2, simTelemetryVenom11: 3, navTelemetryVenom11: 4, simTelemetryVenom12: 5, navTelemetryVenom12: 6, scenarioStart: 7, scenarioEnd: 8, } |
1 2 3 4 5 6 7 8 9 10 11 12 | var i =0; const Topics = { NullTopic: i++, simActorStateTest: i++, navActorStateTest: i++, simTelemetryVenom11: i++, navTelemetryVenom11: i++, simTelemetryVenom12: i++, navTelemetryVenom12: i++, scenarioStart: i++, scenarioEnd: i++ } |