# cc-enum-type **Repository Path**: howard_chengh/cc-enum-type ## Basic Information - **Project Name**: cc-enum-type - **Description**: No description available - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-05-13 - **Last Updated**: 2022-05-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @hwdcc/enum-type #### 介绍 JavaScript 枚举管理 #### 安装教程 ```sh # pnpm pnpm add @hwdcc/enum-type # yarn yarn add @hwdcc/enum-type # npm npm i -s @hwdcc/enum-type ``` #### 使用说明 ```javascript // EAdStatus.js import { Enum, enumClass, enumComment } from '@cc/enum-type' @enumClass class EAdStatus extends Enum { @enumComment('草稿', 'is-info') static STATUS_1 = 1 @enumComment('审核中', 'is-warning') static STATUS_2 = 2 @enumComment('审核不通过', 'is-danger') static STATUS_3 = 3 } export default EAdStatus; ``` ### 接口方法 #### `Enum.$toCommentList` ```javascript EAdStatus.$toCommentList() // [{id: 1, name: '草稿'},{id: 2, name: '审核中'},{id: 3, name: '审核不通过'}] ``` #### `Enum.$toCommentMapWithValue` ```javascript EAdStatus.$toCommentMapWithValue() // {1: '草稿', 2: '审核中', 3: '审核不通过'} ``` #### `Enum.$toClassNamesMapWithValue` ```javascript EAdStatus.$toClassNamesMapWithValue() // {1: 'is-info', 2: 'is-warning', 3: 'is-danger'} ``` #### `Enum.$toCommentMapWithKey` ```javascript EAdStatus.$toCommentMapWithKey() // {STATUS_1: '草稿', STATUS_2: '审核中', STATUS_3: '审核不通过'} ``` #### `Enum.$comments` ```javascript EAdStatus.$comments // 即 EAdStatus.$toCommentList() // [{id: 1, name: '草稿'},{id: 2, name: '审核中'},{id: 3, name: '审核不通过'}] ``` #### `Enum.$classNames` ```javascript EAdStatus.$classNames // 即 EAdStatus.$toClassNamesMapWithValue() // {1: 'is-info', 2: 'is-warning', 3: 'is-danger'} ``` #### `Enum.$options` ```javascript EAdStatus.$options // 即 EAdStatus.$toCommentList() // [{id: 1, name: '草稿'},{id: 2, name: '审核中'},{id: 3, name: '审核不通过'}] ``` #### `Enum.$toValueWithId` #### `Enum.$toIdWithValue`