@zxhy-npm/enum
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

使用 demo

const verifyStatusEnum = createEnum({
	wait: {
		label: "等待",
		value: 0,
		idx: 1,
	},
	pass: {
		label: "通过",
		value: 1,
		idx: 2,
	},
	reject: {
		label: "拒绝",
		value: 2,
		idx: 3,
	},
	init: {
		label: {
			text: "支付取消",
			status: "Success",
		},
		value: 3,
		idx: 4,
	},
} as const);

// result -> 0
verifyStatusEnum.wait

// result -> {label: "等待", value: 0, idx: 1,}
verifyStatusEnum.waitAll

// result -> 等待
verifyStatusEnum.waitName

// result -> { wait: '等待', pass: '通过', reject: '拒绝', init: { text: '支付取消', status: 'Success' } }
verifyStatusEnum.enum

// result -> { wait: '等待', pass: '通过', reject: '拒绝', init: '支付取消' }
verifyStatusEnum.textEnum

/**
 *
[
  { label: '等待', value: 0, idx: 1 },
  { label: '通过', value: 1, idx: 2 },
  { label: '拒绝', value: 2, idx: 3 },
  { label: { text: '支付取消', status: 'Success' }, value: 3, idx: 4 }
]
 */
verifyStatusEnum.options

更新备注

0.0.3 ---------- 2023-12-14 15:37:44
更新内容: 枚举的key应该是value值
0.0.5 ---------- 2023/12/19 20:26:13
更新内容: labelType的text改为any类型,就可以传dom或者其他类型进来
0.0.2 ---------- 11/7/2024, 5:15:40 PM
更新内容: 增加了All字段

Readme

Keywords

none

Package Sidebar

Install

npm i @zxhy-npm/enum

Weekly Downloads

7

Version

0.0.6

License

MIT

Unpacked Size

3.54 kB

Total Files

4

Last publish

Collaborators

  • henglian123
  • jones_wind
  • liar
  • liukai