# @xiyun/vue-cli-plugin-mock

> ## 简介 mock 插件是为 Vue 项目提供 mock 数据的工具，支持 [Mock.js](https://github.com/nuysoft/Mock/wiki) 语法。

Latest version **1.0.0** (published 2020-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xiyun/vue-cli-plugin-mock
pnpm add @xiyun/vue-cli-plugin-mock
yarn add @xiyun/vue-cli-plugin-mock
bun add @xiyun/vue-cli-plugin-mock
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-03-30 |
| First published | 2020-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 (+12 in 2 direct dependencies) |
| Install scripts | no |
| Author | yuyue |
| Maintainers | changwenxia, huqq123, iamalisa, kybetter, wubaiqing |

## Links

- npm: https://www.npmjs.com/package/@xiyun/vue-cli-plugin-mock
- npm.io page: https://npm.io/package/@xiyun/vue-cli-plugin-mock

## Dependencies (9)

- [ora](https://npm.io/package/ora.md) ^4.0.2
- [cors](https://npm.io/package/cors.md) ^2.8.5
- [glob](https://npm.io/package/glob.md) ^7.1.4
- [mockjs](https://npm.io/package/mockjs.md) ^1.1.0
- [multer](https://npm.io/package/multer.md) ^1.4.2
- [signale](https://npm.io/package/signale.md) ^1.4.0
- [chokidar](https://npm.io/package/chokidar.md) ^3.2.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) ^3.1.0

## Recent versions

- 1.0.0 (latest) — 2020-03-30
- 1.4.14-alpha.12 (canary) — 2020-03-31
- 1.4.14-alpha.10 — 2020-03-30

## README

# @xiyun/vue-cli-plugin-mock

## 简介
mock 插件是为 Vue 项目提供 mock 数据的工具，支持 [Mock.js](https://github.com/nuysoft/Mock/wiki) 语法。

## 安装

```shell
yarn add @xiyun/vue-cli-plugin-mock -D
```

## 示例
package.json 添加如下：
```
"scripts": {
  "start": "vue-cli-service serve --port=8005 --fix",
  ...
}
```
执行命令如下：
```shell
yarn start
```
扫描 __mock__ 目录内所有文件(默认)，默认运行监听模式，mock 文件变化无需重新执行︰

mock 数据文件格式如下︰
```shell
module.exports = {
  '/api/a': { a: 1 }, // 默认 get 请求
  'POST /api/a': { a: 1 },
  '/api/users/:userId': { a: 1 },
  '/api/b': (req, res) => {
    res.end(JSON.stringify({ b: 1 }));
  },
   "/random": function () {
    return Math.random() < 0.1 ? 1 : 0;
  },
  '/api/w':  {
    'list|100': [{ 'value|1-100': 50, 'type|0-2': 1 }], // 支持 Mock.js 语法
  },
};
```

---
_Source: https://npm.io/package/@xiyun/vue-cli-plugin-mock · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
