mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
193 lines
62 KiB
HTML
193 lines
62 KiB
HTML
<!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>Mock 数据 | 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.280d8fbd.js"><link rel="modulepreload" href="/assets/mock.html.c5b87640.js"><link rel="modulepreload" href="/assets/mock.html.a2695a17.js"><link rel="prefetch" href="/assets/index.html.75d6a8bc.js" as="script" /><link rel="prefetch" href="/assets/index.html.6575f8e9.js" as="script" /><link rel="prefetch" href="/assets/builder.html.c5f5eefe.js" as="script" /><link rel="prefetch" href="/assets/config.html.213c47c8.js" as="script" /><link rel="prefetch" href="/assets/contributing.html.9132eed2.js" as="script" /><link rel="prefetch" href="/assets/css.html.690ffa2d.js" as="script" /><link rel="prefetch" href="/assets/directory-structure.html.07f3b602.js" as="script" /><link rel="prefetch" href="/assets/env.html.80d603fd.js" as="script" /><link rel="prefetch" href="/assets/faq.html.8668b2f7.js" as="script" /><link rel="prefetch" href="/assets/getting-started.html.841fbc1e.js" as="script" /><link rel="prefetch" href="/assets/image.html.6172bbbe.js" as="script" /><link rel="prefetch" href="/assets/plugin.html.3b66360a.js" as="script" /><link rel="prefetch" href="/assets/public.html.e31e7d8a.js" as="script" /><link rel="prefetch" href="/assets/route.html.65209dd7.js" as="script" /><link rel="prefetch" href="/assets/runtime-config.html.4b7f2a9f.js" as="script" /><link rel="prefetch" href="/assets/template.html.97432fcc.js" as="script" /><link rel="prefetch" href="/assets/upgrade3.html.ed41d20d.js" as="script" /><link rel="prefetch" href="/assets/api.html.6940fc1d.js" as="script" /><link rel="prefetch" href="/assets/cli.html.e48bbeff.js" as="script" /><link rel="prefetch" href="/assets/index.html.866f6a20.js" as="script" /><link rel="prefetch" href="/assets/index.html.02d97b2d.js" as="script" /><link rel="prefetch" href="/assets/index.html.e4769389.js" as="script" /><link rel="prefetch" href="/assets/index.html.a74cde35.js" as="script" /><link rel="prefetch" href="/assets/index.html.0aa75848.js" as="script" /><link rel="prefetch" href="/assets/api.html.77cd1be3.js" as="script" /><link rel="prefetch" href="/assets/access.html.f8a46f05.js" as="script" /><link rel="prefetch" href="/assets/editor.html.a0da73bf.js" as="script" /><link rel="prefetch" href="/assets/enums.html.4b981d2d.js" as="script" /><link rel="prefetch" href="/assets/icon.html.c5dd430b.js" as="script" /><link rel="prefetch" href="/assets/jest.html.bcb44a81.js" as="script" /><link rel="prefetch" href="/assets/layout.html.62c2bee3.js" as="script" /><link rel="prefetch" href="/assets/locale.html.d26f9a70.js" as="script" /><link rel="prefetch" href="/assets/login.html.7ad210b5.js" as="script" /><link rel="prefetch" href="/assets/model.html.d90a0c56.js" as="script" /><link rel="prefetch" href="/assets/pinia.html.bf709176.js" as="script" /><link rel="prefetch" href="/assets/qiankun.html.29a0db0b.js" as="script" /><link rel="prefetch" href="/assets/request.html.dfadf21d.js" as="script" /><link rel="prefetch" href="/assets/sass.html.256d2d78.js" as="script" /><link rel="prefetch" href="/assets/swc.html.2575c418.js" as="script" /><link rel="prefetch" href="/assets/vuex.html.8d32cff7.js" as="script" /><link rel="prefetch" href="/assets/watermark.html.c23f0fb8.js" as="script" /><link rel="prefetch" href="/assets/windicss.html.0423f6d0.js" as="script" /><link rel="prefetch" href="/assets/404.html.c3e557d0.js" as="script" /><link rel="prefetch" href="/assets/index.html.c52f212d.js" as="script" /><link rel="prefetch" href="/assets/index.html.312d26c3.js" as="script" /><link rel="prefetch" href="/assets/builder.html.8555bf87.js" as="script" /><link rel="prefetch" href="/assets/config.html.2e2af56b.js" as="script" /><link rel="prefetch" href="/assets/contributing.html.1e424a0d.js" as="script" /><link rel="prefetch" href="/assets/css.html.d274c1cf.js" as="script" /><link rel="prefetch" href="/assets/directory-structure.html.3d5d5a55.js" as="script" /><link rel="prefetch" href="/assets/env.html.e8e576dd.js" as="script" /><link rel="prefetch" href="/assets/faq.html.f27e987c.js" as="script" /><link rel="prefetch" href="/assets/getting-started.html.66ad38c8.js" as="script" /><link rel="prefetch" href="/assets/image.html.15181c2a.js" as="script" /><link rel="prefetch" href="/assets/plugin.html.cf5b48e8.js" as="script" /><link rel="prefetch" href="/assets/public.html.899969e7.js" as="script" /><link rel="prefetch" href="/assets/route.html.68614345.js" as="script" /><link rel="prefetch" href="/assets/runtime-config.html.905c4866.js" as="script" /><link rel="prefetch" href="/assets/template.html.22225cf7.js" as="script" /><link rel="prefetch" href="/assets/upgrade3.html.e7447822.js" as="script" /><link rel="prefetch" href="/assets/api.html.787b8b4f.js" as="script" /><link rel="prefetch" href="/assets/cli.html.f340ccb7.js" as="script" /><link rel="prefetch" href="/assets/index.html.c5e3b493.js" as="script" /><link rel="prefetch" href="/assets/index.html.bec84bd7.js" as="script" /><link rel="prefetch" href="/assets/index.html.04fc8e88.js" as="script" /><link rel="prefetch" href="/assets/index.html.38a67060.js" as="script" /><link rel="prefetch" href="/assets/index.html.b15299b0.js" as="script" /><link rel="prefetch" href="/assets/api.html.b7ed840f.js" as="script" /><link rel="prefetch" href="/assets/access.html.410b3c0f.js" as="script" /><link rel="prefetch" href="/assets/editor.html.59fef6b7.js" as="script" /><link rel="prefetch" href="/assets/enums.html.2ca6600d.js" as="script" /><link rel="prefetch" href="/assets/icon.html.d2338873.js" as="script" /><link rel="prefetch" href="/assets/jest.html.be946c94.js" as="script" /><link rel="prefetch" href="/assets/layout.html.2d6a0e94.js" as="script" /><link rel="prefetch" href="/assets/locale.html.434577af.js" as="script" /><link rel="prefetch" href="/assets/login.html.bffad39d.js" as="script" /><link rel="prefetch" href="/assets/model.html.f525f1b0.js" as="script" /><link rel="prefetch" href="/assets/pinia.html.2b2c732c.js" as="script" /><link rel="prefetch" href="/assets/qiankun.html.c2f35d68.js" as="script" /><link rel="prefetch" href="/assets/request.html.1f4b526d.js" as="script" /><link rel="prefetch" href="/assets/sass.html.f32e7ef4.js" as="script" /><link rel="prefetch" href="/assets/swc.html.95d22614.js" as="script" /><link rel="prefetch" href="/assets/vuex.html.fed34f71.js" as="script" /><link rel="prefetch" href="/assets/watermark.html.236d3599.js" as="script" /><link rel="prefetch" href="/assets/windicss.html.9d7e3400.js" as="script" /><link rel="prefetch" href="/assets/404.html.92d7c418.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="router-link-active" 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="" 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="router-link-active" 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="" 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><p tabindex="0" class="sidebar-item sidebar-heading">介绍 <!----></p><ul style="" class="sidebar-item-children"><!--[--><li><a href="/guide/" class="router-link-active sidebar-item" aria-label="介绍"><!--[--><!--]--> 介绍 <!--[--><!--]--></a><!----></li><li><a href="/guide/getting-started.html" class="sidebar-item" aria-label="快速上手"><!--[--><!--]--> 快速上手 <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><p tabindex="0" class="sidebar-item sidebar-heading active">基础 <!----></p><ul style="" class="sidebar-item-children"><!--[--><li><a href="/guide/directory-structure.html" class="sidebar-item" aria-label="目录结构"><!--[--><!--]--> 目录结构 <!--[--><!--]--></a><!----></li><li><a href="/guide/builder.html" class="sidebar-item" aria-label="支持 Vite 和 Webpack 双构建"><!--[--><!--]--> 支持 Vite 和 Webpack 双构建 <!--[--><!--]--></a><!----></li><li><a href="/guide/config.html" class="sidebar-item" aria-label="编译时配置"><!--[--><!--]--> 编译时配置 <!--[--><!--]--></a><!----></li><li><a href="/guide/runtime-config.html" class="sidebar-item" aria-label="运行时配置"><!--[--><!--]--> 运行时配置 <!--[--><!--]--></a><!----></li><li><a href="/guide/env.html" class="sidebar-item" aria-label="环境变量"><!--[--><!--]--> 环境变量 <!--[--><!--]--></a><!----></li><li><a href="/guide/route.html" class="sidebar-item" aria-label="路由"><!--[--><!--]--> 路由 <!--[--><!--]--></a><!----></li><li><a href="/guide/plugin.html" class="sidebar-item" aria-label="插件"><!--[--><!--]--> 插件 <!--[--><!--]--></a><!----></li><li><a href="/guide/template.html" class="sidebar-item" aria-label="HTML 模板"><!--[--><!--]--> HTML 模板 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/guide/mock.html" class="router-link-active router-link-exact-active router-link-active sidebar-item active" aria-label="Mock 数据"><!--[--><!--]--> Mock 数据 <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/guide/mock.html#约定式-mock-文件" class="router-link-active router-link-exact-active sidebar-item" aria-label="约定式 Mock 文件"><!--[--><!--]--> 约定式 Mock 文件 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/guide/mock.html#编写-mock-文件" class="router-link-active router-link-exact-active sidebar-item" aria-label="编写 Mock 文件"><!--[--><!--]--> 编写 Mock 文件 <!--[--><!--]--></a><ul style="" class="sidebar-item-children"><!--[--><li><a aria-current="page" href="/guide/mock.html#cgimock-参数" class="router-link-active router-link-exact-active sidebar-item" aria-label="cgiMock 参数"><!--[--><!--]--> cgiMock 参数 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/guide/mock.html#mockjs-参数" class="router-link-active router-link-exact-active sidebar-item" aria-label="mockjs 参数"><!--[--><!--]--> mockjs 参数 <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/guide/mock.html#utils-参数" class="router-link-active router-link-exact-active sidebar-item" aria-label="utils 参数"><!--[--><!--]--> utils 参数 <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><a aria-current="page" href="/guide/mock.html#配置-mock" class="router-link-active router-link-exact-active sidebar-item" aria-label="配置 Mock"><!--[--><!--]--> 配置 Mock <!--[--><!--]--></a><!----></li><li><a aria-current="page" href="/guide/mock.html#关闭-mock" class="router-link-active router-link-exact-active sidebar-item" aria-label="关闭 Mock"><!--[--><!--]--> 关闭 Mock <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><a href="/guide/upgrade3.html" class="sidebar-item" aria-label="从 2.0.x 迁移到 3.0.x"><!--[--><!--]--> 从 2.0.x 迁移到 3.0.x <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><p tabindex="0" class="sidebar-item sidebar-heading">样式和资源文件 <!----></p><ul style="" class="sidebar-item-children"><!--[--><li><a href="/guide/image.html" class="sidebar-item" aria-label="使用图片"><!--[--><!--]--> 使用图片 <!--[--><!--]--></a><!----></li><li><a href="/guide/css.html" class="sidebar-item" aria-label="使用 css"><!--[--><!--]--> 使用 css <!--[--><!--]--></a><!----></li><li><a href="/guide/public.html" class="sidebar-item" aria-label="静态资源"><!--[--><!--]--> 静态资源 <!--[--><!--]--></a><!----></li><!--]--></ul></li><li><a href="/guide/contributing.html" class="sidebar-item sidebar-heading" aria-label="贡献指南"><!--[--><!--]--> 贡献指南 <!--[--><!--]--></a><!----></li><li><a href="/guide/faq.html" class="sidebar-item sidebar-heading" aria-label="常见问题"><!--[--><!--]--> 常见问题 <!--[--><!--]--></a><!----></li><!--]--></ul><!--[--><!--]--></aside><!--]--><!--[--><main class="page"><!--[--><!--]--><div class="theme-default-content"><!--[--><!--]--><div><h1 id="mock-数据" tabindex="-1"><a class="header-anchor" href="#mock-数据" aria-hidden="true">#</a> Mock 数据</h1><p>Mock 数据是前端开发过程中必不可少的一环,是分离前后端开发的关键链路。通过预先跟服务器端约定好的接口,模拟请求数据甚至逻辑,能够让前端开发独立自主,不会被服务端的开发所阻塞。</p><h2 id="约定式-mock-文件" tabindex="-1"><a class="header-anchor" href="#约定式-mock-文件" aria-hidden="true">#</a> 约定式 Mock 文件</h2><p>Fes.js 约定 <code>./mock.js</code> 为 mock 文件。</p><p>比如:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>.
|
||
├── mock.js
|
||
└── src
|
||
└── pages
|
||
└── index.vue
|
||
</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></div><h2 id="编写-mock-文件" tabindex="-1"><a class="header-anchor" href="#编写-mock-文件" aria-hidden="true">#</a> 编写 Mock 文件</h2><p>可以参考如下 🌰:</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> cgiMock<span class="token punctuation">,</span> mockjs<span class="token punctuation">,</span> utils <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||
<span class="token keyword">const</span> <span class="token punctuation">{</span> Random <span class="token punctuation">}</span> <span class="token operator">=</span> mockjs<span class="token punctuation">;</span>
|
||
|
||
<span class="token comment">// 测试 proxy 与 mock 用例集合</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token string">'/movie/in_theaters_mock'</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token parameter">req<span class="token punctuation">,</span> res</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||
res<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span>
|
||
<span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token literal-property property">code</span><span class="token operator">:</span> <span class="token string">'0'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">msg</span><span class="token operator">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">result</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">text</span><span class="token operator">:</span> <span class="token string">'movie: movie/in_theaters_mock ~~~~~'</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><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token string">'/movie/test_mock'</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token parameter">req<span class="token punctuation">,</span> res</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||
res<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span>
|
||
<span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token literal-property property">code</span><span class="token operator">:</span> <span class="token string">'0'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">msg</span><span class="token operator">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">result</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">text</span><span class="token operator">:</span> <span class="token string">'mock: movie/test_mock'</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><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token comment">// 测试用例: mock.js change,重现请求,需要能拉最新的数据</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token string">'/watchtest'</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token parameter">req<span class="token punctuation">,</span> res</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||
res<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span>
|
||
<span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token literal-property property">code</span><span class="token operator">:</span> <span class="token string">'0'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">msg</span><span class="token operator">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">result</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">text</span><span class="token operator">:</span> <span class="token string">'通过 register 测试 mock watch: 初始状态'</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><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token comment">// 返回一个数字</span>
|
||
<span class="token comment">// cgiMock('/number', 666);</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token string">'/number'</span><span class="token punctuation">,</span> <span class="token number">999</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token comment">// 返回一个json</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token literal-property property">url</span><span class="token operator">:</span> <span class="token string">'/json'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">result</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">code</span><span class="token operator">:</span> <span class="token string">'400101'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">msg</span><span class="token operator">:</span> <span class="token string">"不合法的请求:Missing cookie 'wb_app_id' for method parameter of type String"</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">transactionTime</span><span class="token operator">:</span> <span class="token string">'20170309171146'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">success</span><span class="token operator">:</span> <span class="token boolean">false</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 comment">// 利用 mock.js 产生随机文本</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token string">'/text'</span><span class="token punctuation">,</span> Random<span class="token punctuation">.</span><span class="token function">cparagraph</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">// 返回一个字符串 利用 mock.js 产生随机字符</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span>
|
||
<span class="token string">'/random'</span><span class="token punctuation">,</span>
|
||
mockjs<span class="token punctuation">.</span><span class="token function">mock</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token string-property property">'string|1-10'</span><span class="token operator">:</span> <span class="token string">'★'</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 comment">// 正则匹配url, 返回一个字符串</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\/abc|\/xyz</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token string">'regexp test!'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token comment">// option.result 参数如果是一个函数, 可以实现自定义返回内容, 接收的参数是是经过 express 封装的 req 和 res 对象.</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\/function$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token parameter">req<span class="token punctuation">,</span> res</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||
res<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span><span class="token string">'function test'</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 comment">// 返回文本 readFileSync</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token string">'/file'</span><span class="token punctuation">,</span> utils<span class="token punctuation">.</span><span class="token function">file</span><span class="token punctuation">(</span><span class="token string">'./package.json'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token comment">// 更复杂的规则配置</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token literal-property property">url</span><span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\/who</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">method</span><span class="token operator">:</span> <span class="token string">'GET'</span><span class="token punctuation">,</span>
|
||
<span class="token function">result</span><span class="token punctuation">(</span><span class="token parameter">req<span class="token punctuation">,</span> res</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||
<span class="token keyword">if</span> <span class="token punctuation">(</span>req<span class="token punctuation">.</span>query<span class="token punctuation">.</span>name <span class="token operator">===</span> <span class="token string">'kwan'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||
res<span class="token punctuation">.</span><span class="token function">json</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token literal-property property">kwan</span><span class="token operator">:</span> <span class="token string">'孤独患者'</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
|
||
res<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span><span class="token string">'Nooooooooooo'</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">headers</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token string-property property">'Content-Type'</span><span class="token operator">:</span> <span class="token string">'text/plain'</span><span class="token punctuation">,</span>
|
||
<span class="token string-property property">'Content-Length'</span><span class="token operator">:</span> <span class="token string">'123'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">ETag</span><span class="token operator">:</span> <span class="token string">'12345'</span><span class="token punctuation">,</span>
|
||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">cookies</span><span class="token operator">:</span> <span class="token punctuation">[</span>
|
||
<span class="token punctuation">{</span>
|
||
<span class="token literal-property property">name</span><span class="token operator">:</span> <span class="token string">'myname'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">value</span><span class="token operator">:</span> <span class="token string">'kwan'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">maxAge</span><span class="token operator">:</span> <span class="token number">900000</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">httpOnly</span><span class="token operator">:</span> <span class="token boolean">true</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 comment">// 携带参数的请求</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token string">'/v2/audit/list'</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token parameter">req<span class="token punctuation">,</span> res</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||
<span class="token keyword">const</span> <span class="token punctuation">{</span> currentPage<span class="token punctuation">,</span> pageSize<span class="token punctuation">,</span> isAudited <span class="token punctuation">}</span> <span class="token operator">=</span> req<span class="token punctuation">.</span>body<span class="token punctuation">;</span>
|
||
res<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token literal-property property">code</span><span class="token operator">:</span> <span class="token string">'0'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">msg</span><span class="token operator">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">data</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
currentPage<span class="token punctuation">,</span>
|
||
pageSize<span class="token punctuation">,</span>
|
||
<span class="token literal-property property">totalPage</span><span class="token operator">:</span> <span class="token number">2</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">totalCount</span><span class="token operator">:</span> <span class="token number">12</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">pageData</span><span class="token operator">:</span> Array<span class="token punctuation">.</span><span class="token function">from</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token literal-property property">length</span><span class="token operator">:</span> pageSize <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token literal-property property">title</span><span class="token operator">:</span> Random<span class="token punctuation">.</span><span class="token function">title</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">authorName</span><span class="token operator">:</span> Random<span class="token punctuation">.</span><span class="token function">cname</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">authorId</span><span class="token operator">:</span> Random<span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">createTime</span><span class="token operator">:</span> Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">updateTime</span><span class="token operator">:</span> Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">readCount</span><span class="token operator">:</span> Random<span class="token punctuation">.</span><span class="token function">integer</span><span class="token punctuation">(</span><span class="token number">60</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">favoriteCount</span><span class="token operator">:</span> Random<span class="token punctuation">.</span><span class="token function">integer</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">postId</span><span class="token operator">:</span> <span class="token string">'12323'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">serviceTag</span><span class="token operator">:</span> <span class="token string">'业务类型'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">productTag</span><span class="token operator">:</span> <span class="token string">'产品类型'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">requestTag</span><span class="token operator">:</span> <span class="token string">'需求类型'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">handleTag</span><span class="token operator">:</span> <span class="token string">'已采纳'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">postType</span><span class="token operator">:</span> <span class="token string">'voice'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">postStatus</span><span class="token operator">:</span> isAudited <span class="token operator">?</span> <span class="token string">'pass'</span> <span class="token operator">:</span> <span class="token string">'auditing'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">auditStatus</span><span class="token operator">:</span> <span class="token string">'audit1'</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><span class="token punctuation">;</span>
|
||
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
||
|
||
<span class="token comment">// multipart/form-data 类型</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span><span class="token string">'/v2/upload'</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token parameter">req<span class="token punctuation">,</span> res</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||
res<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token literal-property property">code</span><span class="token operator">:</span> <span class="token string">'0'</span><span class="token punctuation">,</span>
|
||
<span class="token literal-property property">msg</span><span class="token operator">:</span> <span class="token string">'文件上传成功'</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 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 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 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="cgimock-参数" tabindex="-1"><a class="header-anchor" href="#cgimock-参数" aria-hidden="true">#</a> cgiMock 参数</h3><p>创建一个 mock 接口,参数非常灵活,参考上面的 demo 即可。</p><h3 id="mockjs-参数" tabindex="-1"><a class="header-anchor" href="#mockjs-参数" aria-hidden="true">#</a> mockjs 参数</h3><p><a href="http://mockjs.com/" target="_blank" rel="noopener noreferrer">Mock.js<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> 是常用的辅助生成模拟数据的三方库,借助他可以提升我们的 mock 数据能力。</p><p>比如:</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> cgiMock<span class="token punctuation">,</span> mockjs<span class="token punctuation">,</span> utils <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||
<span class="token function">cgiMock</span><span class="token punctuation">(</span>
|
||
<span class="token string">'/random'</span><span class="token punctuation">,</span>
|
||
mockjs<span class="token punctuation">.</span><span class="token function">mock</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
|
||
<span class="token string-property property">'string|1-10'</span><span class="token operator">:</span> <span class="token string">'★'</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></div><h3 id="utils-参数" tabindex="-1"><a class="header-anchor" href="#utils-参数" aria-hidden="true">#</a> utils 参数</h3><p>工具函数:</p><ul><li>utils.file(path),从项目根目录根据 path 寻找文件,返回文件流。</li></ul><h2 id="配置-mock" tabindex="-1"><a class="header-anchor" href="#配置-mock" aria-hidden="true">#</a> 配置 Mock</h2><p>详见配置 <a href="/reference/config/#mock" class="">mock</a>。</p><h2 id="关闭-mock" tabindex="-1"><a class="header-anchor" href="#关闭-mock" aria-hidden="true">#</a> 关闭 Mock</h2><p>可以通过配置关闭。</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
|
||
<span class="token literal-property property">mock</span><span class="token operator">:</span> <span class="token boolean">false</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></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/guide/mock.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="/guide/template.html" class="" aria-label="HTML 模板"><!--[--><!--]--> HTML 模板 <!--[--><!--]--></a></span><span class="next"><a href="/guide/upgrade3.html" class="" aria-label="从 2.0.x 迁移到 3.0.x"><!--[--><!--]--> 从 2.0.x 迁移到 3.0.x <!--[--><!--]--></a></span></p></nav><!--[--><!--]--></main><!--]--></div><!----><!----><!--]--></div>
|
||
<script type="module" src="/assets/app.280d8fbd.js" defer></script>
|
||
</body>
|
||
</html>
|