官网地址:http://mockjs.com/
RAP: http://rapapi.org/org/index.do
一、mock步骤
1、安装mockjs
cnpm install mockjs --save-dev
2、在src目录下创建mock.js
import Mock from 'mockjs'; export default Mock.mock('http://vhen.com', { 'name' : '@name', 'age|1-100': 100, 'color' : '@color' });
Mock.mock('data', {/*地址任意*/
'result|5': [{
'id|+1': 1,
'email': '@EMAIL',
'name':'@STRING'
}]
});
3、main.js 主入口引入mock.js
import '@/mock';
4、组件中调用
methods: { getData () { this.$http.get('http://vhen.com').then(res => { console.log('sdfdsfsf', res) }) } },
二、RAP
1、接口请求参数
2、接口响应参数
3、结果
{ "StaticUserReportVO ": [ { "subGains": 899.334, "subMoney": 346, "subRebate ": 0.08, "subRecharge ": 285, "subWithdrawal": 539, "totalGains": 712, "totalMoney ": 716, "totalRebate ": 0.25, "totalRecharge ": 413, "totalWithdrawal": 100.29 }, { "subGains": 703.708, "subMoney": 569, "subRebate ": 1.35, "subRecharge ": 689, "subWithdrawal": 669, "totalGains": 494, "totalMoney ": 559, "totalRebate ": 0.01, "totalRecharge ": 169, "totalWithdrawal": 100.173 }, { "subGains": 124.573, "subMoney": 451, "subRebate ": 0.08, "subRecharge ": 587, "subWithdrawal": 317, "totalGains": 533, "totalMoney ": 136, "totalRebate ": 1.16, "totalRecharge ": 457, "totalWithdrawal": 100.436 }, { "subGains": 397.841, "subMoney": 917, "subRebate ": 1.47, "subRecharge ": 578, "subWithdrawal": 741, "totalGains": 534, "totalMoney ": 327, "totalRebate ": 0.2, "totalRecharge ": 362, "totalWithdrawal": 100.853 }, { "subGains": 433.607, "subMoney": 387, "subRebate ": 0.63, "subRecharge ": 559, "subWithdrawal": 249, "totalGains": 124, "totalMoney ": 495, "totalRebate ": 1.63, "totalRecharge ": 781, "totalWithdrawal": 100.518 }, { "subGains": 210.285, "subMoney": 681, "subRebate ": 1.63, "subRecharge ": 470, "subWithdrawal": 267, "totalGains": 248, "totalMoney ": 926, "totalRebate ": 1.83, "totalRecharge ": 777, "totalWithdrawal": 100.796 }, { "subGains": 872.763, "subMoney": 199, "subRebate ": 1.32, "subRecharge ": 638, "subWithdrawal": 610, "totalGains": 573, "totalMoney ": 883, "totalRebate ": 1.78, "totalRecharge ": 674, "totalWithdrawal": 100.522 }, { "subGains": 478.677, "subMoney": 917, "subRebate ": 0.32, "subRecharge ": 499, "subWithdrawal": 705, "totalGains": 468, "totalMoney ": 374, "totalRebate ": 1.93, "totalRecharge ": 991, "totalWithdrawal": 100.434 }, { "subGains": 600.124, "subMoney": 521, "subRebate ": 0.22, "subRecharge ": 112, "subWithdrawal": 624, "totalGains": 267, "totalMoney ": 440, "totalRebate ": 1.63, "totalRecharge ": 269, "totalWithdrawal": 100.568 }, { "subGains": 611.561, "subMoney": 598, "subRebate ": 1.51, "subRecharge ": 194, "subWithdrawal": 182, "totalGains": 375, "totalMoney ": 733, "totalRebate ": 0.88, "totalRecharge ": 512, "totalWithdrawal": 100.978 } ], "UserReportResVO": [ { "isSubUser": true, "count": 79, "gains": 863.882, "money": 721.583, "rebate": 0.26, "recharge ": 100.863, "userId": 1, "userName": "Margaret Taylor", "withdrawal ": 497 }, { "isSubUser": true, "count": 12, "gains": 202.873, "money": 611.332, "rebate": 0.83, "recharge ": 100.723, "userId": 2, "userName": "Timothy Hernandez", "withdrawal ": 769 }, { "isSubUser": false, "count": 63, "gains": 720.117, "money": 495.546, "rebate": 1.16, "recharge ": 100.57, "userId": 3, "userName": "Joseph Wilson", "withdrawal ": 574 }, { "isSubUser": true, "count": 93, "gains": 298.103, "money": 140.858, "rebate": 0.42, "recharge ": 100.233, "userId": 4, "userName": "Laura Perez", "withdrawal ": 737 }, { "isSubUser": false, "count": 85, "gains": 449.766, "money": 836.232, "rebate": 1.45, "recharge ": 100.673, "userId": 5, "userName": "Sarah Taylor", "withdrawal ": 187 } ] }