1. 安装 mock.js
npm install mockjs --save
2.在src 下面建 mock/mock.js
import Mock from 'mockjs'Mock.mock('/api/login', 'post', (data) =>{return {'msg': 'success','token': 'admin'} })
请求数据
addFun () {axios.post('/api/login').then(function (response) {console.log(response)}).catch(function (error) {console.log(error)}) }