163 lines
61 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="VuePress 2.0.0-beta.53">
<style>
:root {
--c-bg: #fff;
}
html.dark {
--c-bg: #22272e;
}
html, body {
background-color: var(--c-bg);
}
</style>
<script>
const userMode = localStorage.getItem('vuepress-color-scheme');
const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
document.documentElement.classList.toggle('dark', true);
}
</script>
<link rel="manifest" href="/manifest.webmanifest"><link rel="icon" href="/logo.png"><title>@fesjs/plugin-enums | Fes.js</title><meta name="description" content="一个好用的前端应用解决方案">
<link rel="preload" href="/assets/style.03dc0593.css" as="style" /><link rel="stylesheet" href="/assets/style.03dc0593.css" />
<link rel="modulepreload" href="/assets/app.bd9c95b7.js"><link rel="modulepreload" href="/assets/enums.html.2b56cb9b.js"><link rel="modulepreload" href="/assets/enums.html.9eba9e94.js"><link rel="prefetch" href="/assets/index.html.c52ea2ee.js" as="script" /><link rel="prefetch" href="/assets/index.html.4ecf73ea.js" as="script" /><link rel="prefetch" href="/assets/builder.html.246dbbe3.js" as="script" /><link rel="prefetch" href="/assets/config.html.637a9806.js" as="script" /><link rel="prefetch" href="/assets/contributing.html.8f3528e9.js" as="script" /><link rel="prefetch" href="/assets/css.html.f4729d94.js" as="script" /><link rel="prefetch" href="/assets/directory-structure.html.c7ccc960.js" as="script" /><link rel="prefetch" href="/assets/env.html.2fbe8f51.js" as="script" /><link rel="prefetch" href="/assets/faq.html.7f01d8a8.js" as="script" /><link rel="prefetch" href="/assets/getting-started.html.f4fdc148.js" as="script" /><link rel="prefetch" href="/assets/image.html.f92a08c2.js" as="script" /><link rel="prefetch" href="/assets/mock.html.561d68eb.js" as="script" /><link rel="prefetch" href="/assets/plugin.html.a5e6ae94.js" as="script" /><link rel="prefetch" href="/assets/public.html.950ba2eb.js" as="script" /><link rel="prefetch" href="/assets/route.html.8edafb3a.js" as="script" /><link rel="prefetch" href="/assets/runtime-config.html.b70d36d5.js" as="script" /><link rel="prefetch" href="/assets/template.html.900fbffc.js" as="script" /><link rel="prefetch" href="/assets/upgrade3.html.9bc44b95.js" as="script" /><link rel="prefetch" href="/assets/api.html.dd7de804.js" as="script" /><link rel="prefetch" href="/assets/cli.html.eb7c8bac.js" as="script" /><link rel="prefetch" href="/assets/index.html.833852a3.js" as="script" /><link rel="prefetch" href="/assets/index.html.4f4b557d.js" as="script" /><link rel="prefetch" href="/assets/index.html.1e4e9bb2.js" as="script" /><link rel="prefetch" href="/assets/index.html.4b24c667.js" as="script" /><link rel="prefetch" href="/assets/index.html.b99c3eab.js" as="script" /><link rel="prefetch" href="/assets/api.html.ad50f750.js" as="script" /><link rel="prefetch" href="/assets/access.html.ccef700f.js" as="script" /><link rel="prefetch" href="/assets/editor.html.45b1bf75.js" as="script" /><link rel="prefetch" href="/assets/icon.html.1ef9becf.js" as="script" /><link rel="prefetch" href="/assets/jest.html.b6be70f6.js" as="script" /><link rel="prefetch" href="/assets/layout.html.737f0d05.js" as="script" /><link rel="prefetch" href="/assets/locale.html.a0788058.js" as="script" /><link rel="prefetch" href="/assets/login.html.3b52bc00.js" as="script" /><link rel="prefetch" href="/assets/model.html.a33983f1.js" as="script" /><link rel="prefetch" href="/assets/pinia.html.ca207361.js" as="script" /><link rel="prefetch" href="/assets/qiankun.html.fd060b60.js" as="script" /><link rel="prefetch" href="/assets/request.html.d16e6c85.js" as="script" /><link rel="prefetch" href="/assets/sass.html.be3aee7e.js" as="script" /><link rel="prefetch" href="/assets/swc.html.86a67f1f.js" as="script" /><link rel="prefetch" href="/assets/vuex.html.3e9bd488.js" as="script" /><link rel="prefetch" href="/assets/watermark.html.6ba7e245.js" as="script" /><link rel="prefetch" href="/assets/windicss.html.17a13504.js" as="script" /><link rel="prefetch" href="/assets/404.html.c3e557d0.js" as="script" /><link rel="prefetch" href="/assets/index.html.de0d80a1.js" as="script" /><link rel="prefetch" href="/assets/index.html.9f427ef5.js" as="script" /><link rel="prefetch" href="/assets/builder.html.5491993d.js" as="script" /><link rel="prefetch" href="/assets/config.html.bebaf600.js" as="script" /><link rel="prefetch" href="/assets/contributing.html.3aa886b1.js" as="script" /><link rel="prefetch" href="/assets/css.html.8c2b9f6e.js" as="script" /><link rel="prefetch" href="/assets/directory-structure.html.c7e6fd2d.js" as="script" /><link rel="prefetch" href="/assets/env.html.5728b740.js" as="script" /><link rel="prefetch" href="/assets/faq.html.d692a6e2.js" as="script" /><link rel="prefetch" href="/assets/getting-started.html.0eb9c5e2.js" as="script" /><link rel="prefetch" href="/assets/image.html.50bf0bdd.js" as="script" /><link rel="prefetch" href="/assets/mock.html.ab147021.js" as="script" /><link rel="prefetch" href="/assets/plugin.html.de4f8c7b.js" as="script" /><link rel="prefetch" href="/assets/public.html.d51b184d.js" as="script" /><link rel="prefetch" href="/assets/route.html.32be9bfc.js" as="script" /><link rel="prefetch" href="/assets/runtime-config.html.90acb818.js" as="script" /><link rel="prefetch" href="/assets/template.html.8e33412a.js" as="script" /><link rel="prefetch" href="/assets/upgrade3.html.c353af42.js" as="script" /><link rel="prefetch" href="/assets/api.html.87969763.js" as="script" /><link rel="prefetch" href="/assets/cli.html.af8c16d8.js" as="script" /><link rel="prefetch" href="/assets/index.html.9bf5bab1.js" as="script" /><link rel="prefetch" href="/assets/index.html.cbd2c491.js" as="script" /><link rel="prefetch" href="/assets/index.html.a2d6e9e6.js" as="script" /><link rel="prefetch" href="/assets/index.html.2877eae5.js" as="script" /><link rel="prefetch" href="/assets/index.html.d2f518d0.js" as="script" /><link rel="prefetch" href="/assets/api.html.06ea97fd.js" as="script" /><link rel="prefetch" href="/assets/access.html.1a82486a.js" as="script" /><link rel="prefetch" href="/assets/editor.html.0d361fe8.js" as="script" /><link rel="prefetch" href="/assets/icon.html.09e6d802.js" as="script" /><link rel="prefetch" href="/assets/jest.html.da327ef6.js" as="script" /><link rel="prefetch" href="/assets/layout.html.18970df4.js" as="script" /><link rel="prefetch" href="/assets/locale.html.669c5454.js" as="script" /><link rel="prefetch" href="/assets/login.html.5cb3e152.js" as="script" /><link rel="prefetch" href="/assets/model.html.17d86d37.js" as="script" /><link rel="prefetch" href="/assets/pinia.html.eb251b6e.js" as="script" /><link rel="prefetch" href="/assets/qiankun.html.03151319.js" as="script" /><link rel="prefetch" href="/assets/request.html.08c691d1.js" as="script" /><link rel="prefetch" href="/assets/sass.html.9236bc5e.js" as="script" /><link rel="prefetch" href="/assets/swc.html.1459de3d.js" as="script" /><link rel="prefetch" href="/assets/vuex.html.1794fc22.js" as="script" /><link rel="prefetch" href="/assets/watermark.html.e99470a0.js" as="script" /><link rel="prefetch" href="/assets/windicss.html.afe09b0e.js" as="script" /><link rel="prefetch" href="/assets/404.html.b697c9e3.js" as="script" /><link rel="prefetch" href="/assets/index.0b6f9a66.js" as="script" />
</head>
<body>
<div id="app"><!--[--><div class="theme-container"><!--[--><header class="navbar"><div class="toggle-sidebar-button" title="toggle sidebar" aria-expanded="false" role="button" tabindex="0"><div class="icon" aria-hidden="true"><span></span><span></span><span></span></div></div><span><a href="/" class=""><img class="logo" src="/logo.png" alt="Fes.js"><span class="site-name can-hide">Fes.js</span></a></span><div class="navbar-items-wrapper" style=""><!--[--><!--]--><nav class="navbar-items can-hide"><!--[--><div class="navbar-item"><a href="/guide/" class="" aria-label="指南"><!--[--><!--]--> 指南 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/reference/config/" class="" aria-label="编译时配置"><!--[--><!--]--> 编译时配置 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/reference/api/" class="" aria-label="API"><!--[--><!--]--> API <!--[--><!--]--></a></div><div class="navbar-item"><a href="/reference/plugin/" class="router-link-active" aria-label="插件"><!--[--><!--]--> 插件 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/reference/cli/" class="" aria-label="CLI"><!--[--><!--]--> CLI <!--[--><!--]--></a></div><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="v3.0.1-0"><span class="title">v3.0.1-0</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="v3.0.1-0"><span class="title">v3.0.1-0</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><a class="external-link" href="https://fesjs.mumblefe.cn/2.0" rel="noopener noreferrer" target="_blank" aria-label="v2.0"><!--[--><!--]--> v2.0 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></li><li class="navbar-dropdown-item"><a class="external-link" href="https://fesjs.mumblefe.cn/1.0" rel="noopener noreferrer" target="_blank" aria-label="v1.0"><!--[--><!--]--> v1.0 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="了解更多"><span class="title">了解更多</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="了解更多"><span class="title">了解更多</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><a class="external-link" href="https://github.com/WeBankFinTech/fes.js/blob/next/CHANGELOG.md" rel="noopener noreferrer" target="_blank" aria-label="更新日志"><!--[--><!--]--> 更新日志 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></li><li class="navbar-dropdown-item"><a class="external-link" href="http://fes-design.mumblefe.cn/" rel="noopener noreferrer" target="_blank" aria-label="fes-design"><!--[--><!--]--> fes-design <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-item"><a class="external-link" href="https://github.com/WeBankFinTech/fes.js" rel="noopener noreferrer" target="_blank" aria-label="GitHub"><!--[--><!--]--> GitHub <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></div><!--]--></nav><!--[--><!--]--><button class="toggle-color-mode-button" title="toggle color mode"><svg style="" class="icon" focusable="false" viewBox="0 0 32 32"><path d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6z" fill="currentColor"></path><path d="M5.394 6.813l1.414-1.415l3.506 3.506L8.9 10.318z" fill="currentColor"></path><path d="M2 15.005h5v2H2z" fill="currentColor"></path><path d="M5.394 25.197L8.9 21.691l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 25.005h2v5h-2z" fill="currentColor"></path><path d="M21.687 23.106l1.414-1.415l3.506 3.506l-1.414 1.414z" fill="currentColor"></path><path d="M25 15.005h5v2h-5z" fill="currentColor"></path><path d="M21.687 8.904l3.506-3.506l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 2.005h2v5h-2z" fill="currentColor"></path></svg><svg style="display:none;" class="icon" focusable="false" viewBox="0 0 32 32"><path d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z" fill="currentColor"></path></svg></button><div id="docsearch-container"></div></div></header><!--]--><div class="sidebar-mask"></div><!--[--><aside class="sidebar"><nav class="navbar-items"><!--[--><div class="navbar-item"><a href="/guide/" class="" aria-label="指南"><!--[--><!--]--> 指南 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/reference/config/" class="" aria-label="编译时配置"><!--[--><!--]--> 编译时配置 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/reference/api/" class="" aria-label="API"><!--[--><!--]--> API <!--[--><!--]--></a></div><div class="navbar-item"><a href="/reference/plugin/" class="router-link-active" aria-label="插件"><!--[--><!--]--> 插件 <!--[--><!--]--></a></div><div class="navbar-item"><a href="/reference/cli/" class="" aria-label="CLI"><!--[--><!--]--> CLI <!--[--><!--]--></a></div><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="v3.0.1-0"><span class="title">v3.0.1-0</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="v3.0.1-0"><span class="title">v3.0.1-0</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><a class="external-link" href="https://fesjs.mumblefe.cn/2.0" rel="noopener noreferrer" target="_blank" aria-label="v2.0"><!--[--><!--]--> v2.0 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></li><li class="navbar-dropdown-item"><a class="external-link" href="https://fesjs.mumblefe.cn/1.0" rel="noopener noreferrer" target="_blank" aria-label="v1.0"><!--[--><!--]--> v1.0 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="了解更多"><span class="title">了解更多</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="了解更多"><span class="title">了解更多</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><a class="external-link" href="https://github.com/WeBankFinTech/fes.js/blob/next/CHANGELOG.md" rel="noopener noreferrer" target="_blank" aria-label="更新日志"><!--[--><!--]--> 更新日志 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></li><li class="navbar-dropdown-item"><a class="external-link" href="http://fes-design.mumblefe.cn/" rel="noopener noreferrer" target="_blank" aria-label="fes-design"><!--[--><!--]--> fes-design <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-item"><a class="external-link" href="https://github.com/WeBankFinTech/fes.js" rel="noopener noreferrer" target="_blank" aria-label="GitHub"><!--[--><!--]--> GitHub <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></div><!--]--></nav><!--[--><!--]--><ul class="sidebar-items"><!--[--><li><a href="/reference/plugin/" class="router-link-active sidebar-item sidebar-heading" aria-label="介绍"><!--[--><!--]--> 介绍 <!--[--><!--]--></a><!----></li><li><p tabindex="0" class="sidebar-item sidebar-heading active">Plugins <!----></p><ul style="" class="sidebar-item-children"><!--[--><li><a href="/reference/plugin/plugins/access.html" class="sidebar-item" aria-label="@fesjs/plugin-access"><!--[--><!--]--> @fesjs/plugin-access <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html" class="router-link-active router-link-exact-active router-link-active sidebar-item active" aria-label="@fesjs/plugin-enums"><!--[--><!--]--> @fesjs/plugin-enums <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#介绍" class="router-link-active router-link-exact-active sidebar-item" aria-label="介绍"><!--[--><!--]--> 介绍 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#启用方式" class="router-link-active router-link-exact-active sidebar-item" aria-label="启用方式"><!--[--><!--]--> 启用方式 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#配置" class="router-link-active router-link-exact-active sidebar-item" aria-label="配置"><!--[--><!--]--> 配置 <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#静态配置" class="router-link-active router-link-exact-active sidebar-item" aria-label="静态配置"><!--[--><!--]--> 静态配置 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#动态配置" class="router-link-active router-link-exact-active sidebar-item" aria-label="动态配置"><!--[--><!--]--> 动态配置 <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#场景使用" class="router-link-active router-link-exact-active sidebar-item" aria-label="场景使用"><!--[--><!--]--> 场景使用 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#api" class="router-link-active router-link-exact-active sidebar-item" aria-label="API"><!--[--><!--]--> API <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#get" class="router-link-active router-link-exact-active sidebar-item" aria-label="get"><!--[--><!--]--> get <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#push" class="router-link-active router-link-exact-active sidebar-item" aria-label="push"><!--[--><!--]--> push <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#remove" class="router-link-active router-link-exact-active sidebar-item" aria-label="remove"><!--[--><!--]--> remove <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#concat" class="router-link-active router-link-exact-active sidebar-item" aria-label="concat"><!--[--><!--]--> concat <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#convert" class="router-link-active router-link-exact-active sidebar-item" aria-label="convert"><!--[--><!--]--> convert <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#extend-配置" class="router-link-active router-link-exact-active sidebar-item" aria-label="extend 配置"><!--[--><!--]--> extend 配置 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/reference/plugin/plugins/enums.html#dir-规则" class="router-link-active router-link-exact-active sidebar-item" aria-label="dir 规则"><!--[--><!--]--> dir 规则 <!--[--><!--]--></a><!----></li><!--]--></ul></li><!--]--></ul></li><li><a href="/reference/plugin/plugins/icon.html" class="sidebar-item" aria-label="@fesjs/plugin-icon"><!--[--><!--]--> @fesjs/plugin-icon <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/jest.html" class="sidebar-item" aria-label="@fesjs/plugin-jest"><!--[--><!--]--> @fesjs/plugin-jest <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/layout.html" class="sidebar-item" aria-label="@fesjs/plugin-layout"><!--[--><!--]--> @fesjs/plugin-layout <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/locale.html" class="sidebar-item" aria-label="@fesjs/plugin-locale"><!--[--><!--]--> @fesjs/plugin-locale <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/model.html" class="sidebar-item" aria-label="@fesjs/plugin-model"><!--[--><!--]--> @fesjs/plugin-model <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/request.html" class="sidebar-item" aria-label="@fesjs/plugin-request"><!--[--><!--]--> @fesjs/plugin-request <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/vuex.html" class="sidebar-item" aria-label="@fesjs/plugin-vuex"><!--[--><!--]--> @fesjs/plugin-vuex <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/qiankun.html" class="sidebar-item" aria-label="@fesjs/plugin-qiankun"><!--[--><!--]--> @fesjs/plugin-qiankun <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/windicss.html" class="sidebar-item" aria-label="@fesjs/plugin-windicss"><!--[--><!--]--> @fesjs/plugin-windicss <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/sass.html" class="sidebar-item" aria-label="@fesjs/plugin-sass"><!--[--><!--]--> @fesjs/plugin-sass <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/editor.html" class="sidebar-item" aria-label="@fesjs/plugin-monaco-editor"><!--[--><!--]--> @fesjs/plugin-monaco-editor <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/pinia.html" class="sidebar-item" aria-label="@fesjs/plugin-pinia"><!--[--><!--]--> @fesjs/plugin-pinia <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/watermark.html" class="sidebar-item" aria-label="@fesjs/plugin-watermark"><!--[--><!--]--> @fesjs/plugin-watermark <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/login.html" class="sidebar-item" aria-label="@fesjs/plugin-login"><!--[--><!--]--> @fesjs/plugin-login <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/plugins/swc.html" class="sidebar-item" aria-label="@fesjs/plugin-swc"><!--[--><!--]--> @fesjs/plugin-swc <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><p tabindex="0" class="sidebar-item sidebar-heading">插件开发 <!----></p><ul style="" class="sidebar-item-children"><!--[--><li><a href="/reference/plugin/dev/" class="sidebar-item" aria-label="插件介绍"><!--[--><!--]--> 插件介绍 <!--[--><!--]--></a><!----></li><li><a href="/reference/plugin/dev/api.html" class="sidebar-item" aria-label="插件 API"><!--[--><!--]--> 插件 API <!--[--><!--]--></a><!----></li><!--]--></ul></li><!--]--></ul><!--[--><!--]--></aside><!--]--><!--[--><main class="page"><!--[--><!--]--><div class="theme-default-content"><!--[--><!--]--><div><h1 id="fesjs-plugin-enums" tabindex="-1"><a class="header-anchor" href="#fesjs-plugin-enums" aria-hidden="true">#</a> @fesjs/plugin-enums</h1><h2 id="介绍" tabindex="-1"><a class="header-anchor" href="#介绍" aria-hidden="true">#</a> 介绍</h2><p>日常业务开发中,有很多场景会使用到枚举值,比如 select-options、table-column。</p><p>该插件提供统一的枚举存取及丰富的函数来处理枚举。</p><h2 id="启用方式" tabindex="-1"><a class="header-anchor" href="#启用方式" aria-hidden="true">#</a> 启用方式</h2><p><code>package.json</code> 中引入依赖:</p><div class="language-json line-numbers-mode" data-ext="json"><pre class="language-json"><code><span class="token punctuation">{</span>
<span class="token property">&quot;dependencies&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">&quot;@fesjs/fes&quot;</span><span class="token operator">:</span> <span class="token string">&quot;^3.0.0&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;@fesjs/plugin-enums&quot;</span><span class="token operator">:</span> <span class="token string">&quot;^3.0.0&quot;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="配置" tabindex="-1"><a class="header-anchor" href="#配置" aria-hidden="true">#</a> 配置</h2><h3 id="静态配置" tabindex="-1"><a class="header-anchor" href="#静态配置" aria-hidden="true">#</a> 静态配置</h3><p><code>.fes.js</code> 中配置:</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token comment">// 配置格式:[[key, value], ...]</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
<span class="token literal-property property">enums</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token literal-property property">status</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">[</span><span class="token string">&#39;0&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;无效的&#39;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">[</span><span class="token string">&#39;1&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;有效的&#39;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="动态配置" tabindex="-1"><a class="header-anchor" href="#动态配置" aria-hidden="true">#</a> 动态配置</h3><p>在业务代码中</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> enums <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&#39;@fesjs/fes&#39;</span><span class="token punctuation">;</span>
<span class="token comment">// 动态添加</span>
enums<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token string">&#39;status&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token punctuation">[</span><span class="token string">&#39;0&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;无效的&#39;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">&#39;1&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;有效的&#39;</span><span class="token punctuation">]</span><span class="token punctuation">]</span>
enums<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&#39;status&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;1&#39;</span><span class="token punctuation">)</span> <span class="token comment">// 有效的</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="场景使用" tabindex="-1"><a class="header-anchor" href="#场景使用" aria-hidden="true">#</a> 场景使用</h2><ul><li><p>动态添加的枚举项支持数组和对象</p></li><li><p>枚举项为对象时,可以指定 keyName 和 valueName 属性名</p></li><li><p>导出枚举值,可指定取值的路径</p></li><li><p>导出枚举可扩展属性</p></li></ul><div class="language-vue line-numbers-mode" data-ext="vue"><pre class="language-vue"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token comment">&lt;!-- 遍历枚举status --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">v-for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>item in enumsGet(&#39;status&#39;)<span class="token punctuation">&quot;</span></span> <span class="token attr-name">:key</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>item.key<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>{{ item.value }}{{ item.key }}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token comment">&lt;!-- 遍历枚举扩展后的roles --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">v-for</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>item in roles<span class="token punctuation">&quot;</span></span> <span class="token attr-name">:key</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>item.key<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>{{ item.name }}{{ item.disabled }}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token comment">&lt;!-- 获取枚举roles为2的英文名 --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">&gt;</span></span>{{ enumsGet(&#39;roles&#39;, &#39;2&#39;, { dir: &#39;eName&#39; }) }}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
<span class="token keyword">import</span> <span class="token punctuation">{</span> enums <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&#39;@fesjs/fes&#39;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
<span class="token function">setup</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token comment">// 动态添加枚举枚举项是对象并指定key的属性名为id</span>
enums<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>
<span class="token string">&#39;roles&#39;</span><span class="token punctuation">,</span>
<span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">id</span><span class="token operator">:</span> <span class="token string">&#39;1&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">cName</span><span class="token operator">:</span> <span class="token string">&#39;系统管理员&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">eName</span><span class="token operator">:</span> <span class="token string">&#39;System&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">perm</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&#39;1&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;2&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;3&#39;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">id</span><span class="token operator">:</span> <span class="token string">&#39;2&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">cName</span><span class="token operator">:</span> <span class="token string">&#39;业务管理员&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">eName</span><span class="token operator">:</span> <span class="token string">&#39;Business&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">perm</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&#39;1&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;2&#39;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">id</span><span class="token operator">:</span> <span class="token string">&#39;3&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">cName</span><span class="token operator">:</span> <span class="token string">&#39;普通用户&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">eName</span><span class="token operator">:</span> <span class="token string">&#39;User&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">perm</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&#39;1&#39;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span> <span class="token literal-property property">keyName</span><span class="token operator">:</span> <span class="token string">&#39;id&#39;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 导出定制格式的roles扩展枚举项新的属性name、disabled</span>
<span class="token keyword">const</span> roles <span class="token operator">=</span> enums<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&#39;roles&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
<span class="token literal-property property">extend</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">key</span><span class="token operator">:</span> <span class="token string">&#39;name&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">dir</span><span class="token operator">:</span> <span class="token string">&#39;cName&#39;</span><span class="token punctuation">,</span> <span class="token comment">// 指定取值路径取属性cName的值</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">key</span><span class="token operator">:</span> <span class="token string">&#39;disabled&#39;</span><span class="token punctuation">,</span>
<span class="token comment">// 传入函数,获取结果值</span>
<span class="token function-variable function">transfer</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">item</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> item<span class="token punctuation">.</span>value<span class="token punctuation">.</span>perm<span class="token punctuation">.</span><span class="token function">some</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">i</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> i <span class="token operator">&gt;=</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>roles<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// [{key: &#39;1&#39;, name: &#39;系统管理员&#39;, disabled: true, value: {...}}, ....]</span>
<span class="token keyword">return</span> <span class="token punctuation">{</span>
<span class="token literal-property property">enumsGet</span><span class="token operator">:</span> enums<span class="token punctuation">.</span>get<span class="token punctuation">,</span>
roles<span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="api" tabindex="-1"><a class="header-anchor" href="#api" aria-hidden="true">#</a> API</h2><h3 id="get" tabindex="-1"><a class="header-anchor" href="#get" aria-hidden="true">#</a> get</h3><ul><li><p><code>get(name: string)</code> 获取指定名字的枚举</p></li><li><p><code>get(name: string, key: string)</code> 获取指定名字及键枚举默认值</p></li><li><p><code>get(name: string, opt: {extend: Array&lt;Object&gt;})</code> 获取指定名字的自定义格式枚举,<a href="#extend%E9%85%8D%E7%BD%AE">查看 extend 配置</a></p></li><li><p><code>get(name: string, key: string, opt: {dir: string})</code> 获取指定名字及键枚举<a href="#dir%E8%A7%84%E5%88%99">dir 规则</a>的值</p></li></ul><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&#39;status&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&#39;status&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;1&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&#39;status&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
<span class="token literal-property property">extend</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">key</span><span class="token operator">:</span> <span class="token string">&#39;name&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">dir</span><span class="token operator">:</span> <span class="token string">&#39;value&#39;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">key</span><span class="token operator">:</span> <span class="token string">&#39;disabled&#39;</span><span class="token punctuation">,</span>
<span class="token function-variable function">transfer</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">item</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> item <span class="token operator">===</span> <span class="token string">&#39;0&#39;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&#39;status&#39;</span><span class="token punctuation">,</span> <span class="token string">&#39;1&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token literal-property property">dir</span><span class="token operator">:</span> <span class="token string">&#39;value&#39;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="push" tabindex="-1"><a class="header-anchor" href="#push" aria-hidden="true">#</a> push</h3><p>动态添加枚举,重复添加会覆盖</p><ul><li><code>push(name: string, _enum: Array&lt;Array&gt;)</code></li><li><code>push(name: string, _enum: Array&lt;Object&gt;, opt?: Object)</code><ul><li>opt.keyName 指定 key 的取值属性,默认是 key</li><li>opt.valueName 指定 value 的取值属性</li></ul></li></ul><p>枚举项为数组,枚举项的[0]解析为 key枚举项的[1]解析为 value</p><p>枚举项为对象时,根据 opt 配置 keyName、valueName 取枚举项属性值分别作为 key 和 value<code>如果valueName未设置则value就是枚举项</code></p><h3 id="remove" tabindex="-1"><a class="header-anchor" href="#remove" aria-hidden="true">#</a> remove</h3><ul><li>remove(name: string)</li></ul><p>移除指定的枚举</p><h3 id="concat" tabindex="-1"><a class="header-anchor" href="#concat" aria-hidden="true">#</a> concat</h3><p>基于现有的枚举,连接上新的枚举后返回新的枚举</p><ul><li><code>concat(name: string, _enum: Array&lt;Array|Object&gt;, opt?: Object))</code><ul><li>opt.keyName 指定 key 的取值属性,默认是 key</li><li>opt.valueName 指定 value 的取值属性</li><li>opt.before 是否添加在现有的之前,默认是 false</li><li>opt.extend返回的枚举<a href="#extend%E9%85%8D%E7%BD%AE">extend 配置</a></li></ul></li></ul><h3 id="convert" tabindex="-1"><a class="header-anchor" href="#convert" aria-hidden="true">#</a> convert</h3><p>将传入的枚举格式转换为{key, value}的形式</p><ul><li><code>convert(name: string, _enum: Array&lt;Array|Object&gt;, opt?: Object))</code><ul><li>opt.keyName 指定 key 的取值属性,默认是 key</li><li>opt.valueName 指定 value 的取值属性</li></ul></li></ul><h3 id="extend-配置" tabindex="-1"><a class="header-anchor" href="#extend-配置" aria-hidden="true">#</a> extend 配置</h3><p>扩展枚举项属性的配置</p><ul><li><code>extend: Array&lt;Object&gt;</code> _ <code>key</code> 指定扩展的属性名 _ <code>dir</code> 指定该属性的取值路径 * <code>transfer(item: {key: any, value: any})</code> 转换函数,参数未枚举项,返回就是该属性的值<div class="custom-container tip"><p class="custom-container-title">提示</p><p>同时设置<a href="#dir%E8%A7%84%E5%88%99">dir</a>和 transfertransfer 优先</p></div></li></ul><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&#39;status&#39;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
<span class="token literal-property property">extend</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">key</span><span class="token operator">:</span> <span class="token string">&#39;name&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">dir</span><span class="token operator">:</span> <span class="token string">&#39;value&#39;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">key</span><span class="token operator">:</span> <span class="token string">&#39;disabled&#39;</span><span class="token punctuation">,</span>
<span class="token function-variable function">transfer</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">item</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> item<span class="token punctuation">.</span>key <span class="token operator">===</span> <span class="token string">&#39;0&#39;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="dir-规则" tabindex="-1"><a class="header-anchor" href="#dir-规则" aria-hidden="true">#</a> dir 规则</h3><p>dir 是指定枚举项 value 的取值方式,规则如下:</p><ul><li>对象属性 <code>A</code><code>A.B</code></li><li>数组 <code>[0]</code><code>[0][1]</code></li><li>混合 <code>A[0]</code><code>[0].A</code><code>A[0].B</code></li></ul><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token comment">// 假如枚举项value的结构如下</span>
<span class="token keyword">const</span> user <span class="token operator">=</span> <span class="token punctuation">{</span>
<span class="token literal-property property">age</span><span class="token operator">:</span> <span class="token number">18</span><span class="token punctuation">,</span>
<span class="token literal-property property">name</span><span class="token operator">:</span> <span class="token string">&#39;aring&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">role</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">id</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
<span class="token literal-property property">name</span><span class="token operator">:</span> <span class="token string">&#39;管理员&#39;</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">{</span>
<span class="token literal-property property">id</span><span class="token operator">:</span> <span class="token number">2</span><span class="token punctuation">,</span>
<span class="token literal-property property">name</span><span class="token operator">:</span> <span class="token string">&#39;业务操作员&#39;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">]</span>
<span class="token punctuation">}</span>
<span class="token comment">// 那么规则解析是:</span>
dir value
<span class="token string">&#39;age&#39;</span> <span class="token operator">=&gt;</span> <span class="token number">18</span>
<span class="token string">&#39;role[0]&#39;</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span><span class="token literal-property property">id</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token literal-property property">name</span><span class="token operator">:</span> <span class="token string">&#39;管理员&#39;</span><span class="token punctuation">}</span>
<span class="token string">&#39;role[1].id&#39;</span> <span class="token operator">=&gt;</span> <span class="token number">2</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">提示</p><p>枚举项 value 如果是基本类型则规则不生效value 就是当前值</p></div></div><!--[--><!--]--></div><footer class="page-meta"><div class="meta-item edit-link"><a class="external-link meta-item-label" href="https://github.com/WeBankFinTech/fes.js/edit/next/docs/reference/plugin/plugins/enums.md" rel="noopener noreferrer" target="_blank" aria-label="在 GitHub 上编辑此页"><!--[--><!--]--> 在 GitHub 上编辑此页 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">在新窗口打开</span></span><!--[--><!--]--></a></div><div class="meta-item last-updated"><span class="meta-item-label">上次更新: </span><!----></div><div class="meta-item contributors"><span class="meta-item-label">贡献者: </span><span class="meta-item-info"><!--[--><!--[--><span class="contributor" title="email: haizekuo@gmail.com">winixt</span><!----><!--]--><!--]--></span></div></footer><nav class="page-nav"><p class="inner"><span class="prev"><a href="/reference/plugin/plugins/access.html" class="" aria-label="@fesjs/plugin-access"><!--[--><!--]--> @fesjs/plugin-access <!--[--><!--]--></a></span><span class="next"><a href="/reference/plugin/plugins/icon.html" class="" aria-label="@fesjs/plugin-icon"><!--[--><!--]--> @fesjs/plugin-icon <!--[--><!--]--></a></span></p></nav><!--[--><!--]--></main><!--]--></div><!----><!----><!--]--></div>
<script type="module" src="/assets/app.bd9c95b7.js" defer></script>
</body>
</html>