开发阶段做一个mock json server,使用这个插件
// 安装
npm i json-server
// 使用,在script里添加
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"server": "json-server --watch db.json -p 5000"
},
// 启动
npm run server
// 会创建一个db.json文件
最新回复