hercule_poirt
^

JSON-Server 模拟接口

1. 安装json-server

npm i json-server -g

2. 在项目根目录新建data.json文件存放接口的数据

data.json配置如下

{
	“users”:[
			{
			“id”:1,
			“name”:name,
			“address”:xxxxxx,
			}
		   ]
}
**json文件中必须使用双引号,不能使用单引号,否则会出现很多错误,导致无法使用**

3. 运行接口文件

json-server data.json

配置端口

json-server --port 5000 data.json
posted @ 2021-10-09 21:16  hercule_poirt  阅读(35)  评论(0)    收藏  举报
Copyright © 2021 hercule_poirt