创建一个枚举元组,EnumArray继承了Array,所以可以用array的各种方法
传入的枚举元组,需要用as const 修饰
返回不可变的EnumArray对象
const sexList = [ { label: '男', value: 1, displayText: '性别男', }, { label: '女', value: 2, }, ] as const const sexEnum = createEnum(sexList) Copy
const sexList = [ { label: '男', value: 1, displayText: '性别男', }, { label: '女', value: 2, }, ] as const const sexEnum = createEnum(sexList)
创建一个枚举元组,EnumArray继承了Array,所以可以用array的各种方法