Jira项目笔记6:配置Mock数据的方法

Mock数据配置

  • 安装json-server
yarn add json-server -D
  • 1.
  • 创建本地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"
},
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 启动json-server
npm run json-server
  • 1.
  • 通过RESTFUL规范添加一条数据
  • 本地Mock数据库已成功添加一条数据



QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利