[TOC]前端
npm install mockjs
import Mock from 'mockjs'
Mock.mock(路徑, 請求方式, 模擬的數據) //路徑:必須是完整的 http://localhost:8080/user //請求方式:get、post 等 //模擬數據:就是postman提供的
// 1 導入mockjs import Mock from 'mockjs' // 2 肯定須要攔截資源:路徑,請求方式,生產模擬數據 Mock.mock('http://localhost:8080/user','get',{ "code": 1, "message": "查詢全部", "data": [ { "uid": 1, "username": "@cname", //@cword "password": "1234", "roleList": [ { "rid": 1, "name": "庫存管理員" }, { "rid": 2, "name": "後臺管理員" } ] }, { "uid": 2, "username": "jack", "password": "1234", "roleList": [ { "rid": 2, "name": "後臺管理員" }, { "rid": 3, "name": "商品管理員" } ] }, { "uid": 3, "username": "rose", "password": "1234", "roleList": [] } ], "other": {} })