1.新建mock数据
2.配置webpack.dev.conf.js
引入express/mock的json文件
const express = require('express')
const goodsJson = require('./../mock/goods.json')
const app = express();
const router = express.Router();
app.use('/api',router);
3.然后找到devServer,在里面添加api配置
before(app){
app.get('/api/goods',(req,res)=>{
res.json(goodsJson)
})
}