Mock数据配置
- 安装json-server
yarn add json-server -D
- 创建本地Mock数据库
- 在package.json中添加script脚本
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"json-server": "json-server __json-server-mock__/db.json --watch"
},
- 启动json-server
npm run json-server
- 通过RESTFUL规范添加一条数据
- 本地Mock数据库已成功添加一条数据