开发阶段做一个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文件
最后编辑:2023年12月12日 ©著作权归作者所有

发表评论