TypeScript学习笔记 枚举类型 2019/11/27 TypeScript JavaScript TypeScript 学习笔记 枚举 一组有名字的常量集合。 枚举的值无法通过外部修改。 数字枚举 下标从0开始,也可指定下标。 enum Role { Reporter, Developer, Maintainer, Owner, Guest}// 0console.log(Role.Reporter);// Reporterconsole.log(Role[0]); 字符串枚举 enum Messade { Success = '恭喜你,成功了', Fail = "抱歉,失败了"}// '恭喜你,成功了'console.log(Messade.Success); 枚举成员 enum Char { //const a, b = Char.a, c = 1 + 3, //computend d = Math.random(), e = '123'.length} 常量枚举 不需要对象,只需要对象得值。 const enum Month { Jan, Fed, Mar}let month = [Month.Jan, Month.Fed, Month.Mar]// [0, 1, 2]console.log(month); TypeScript学习笔记 对象类型接口&函数类型接口 TypeScript学习笔记 构建工具 本文作者:Ihuzb 永久链接:https://ihuzb.github.io/2019/11/27/GK8jzgcyF0/ 版权声明:本文首发于Ihuzb的博客,转载请注明出处!