一、mock安装
D:\workspace\auto0211>cnpm install mockjs --save-dev √ Installed 1 packages √ Linked 1 latest versions √ Run 0 scripts √ All packages installed (1 packages installed from npm registry, used 536ms(network 532ms), speed 9.97kB/s, json 2(5.3kB), tarball 0B)
二、 在src目录下新建mock文件夹,并创建index.js
// 引入mockjs const Mock = require('mockjs'); import { baseurl } from '../api/config' const loginData = { "code": 200, "msg": null, "data": { "id": null, "userId": 1, "token": "77ae89be36504adfb5c09ef71409ea0e", "expireTime": "2018-09-01T16:24:50.473+0000", "createBy": null, "createTime": null, "lastUpdateBy": null, "lastUpdateTime": "2018-09-01T04:24:50.473+0000" } } Mock.mock(baseurl+"/login", 'post', loginData)