1.添加mockjs
1
2 1yarn add mockjs
2
2.在mock目录下新建test.js
List|10,返回list,10条数据
@image,随机生成img的url链接,mock内置函数
1
2
3
4
5
6
7
8
9 1import mockjs from 'mockjs';
2
3export default {
4 'GET /api/img': mockjs.mock({
5 'list|10': [{ src: '@image' }],
6 })
7};
8
9
3.访问:http://localhost:8000/api/img
关于Mock更多参数:https://github.com/nuysoft/Mock/wiki