You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
399 B

2 years ago
  1. // 定义一组枚举命名常量:enum + 名字 {命名常量}
  2. /* enum Direction {
  3. // 枚举成员是有值得,默认从 0 开始自增的数值
  4. Up,
  5. Down,
  6. Left,
  7. Right
  8. } */
  9. enum Direction {
  10. // 可以给枚举中的成员初始化值
  11. Up = 2,
  12. Down = 4,
  13. Left = 8,
  14. Right = 16
  15. }
  16. function changeDirection(direction: Direction) {}
  17. changeDirection(Direction.Up)