安装
npm install -g json-server
使用
在本地创建data.json文件
{
"list1": [
{
"name": "zhangsan",
"age": 50
},
{
"name": "lisi",
"age": 32
},
{
"name": "wangwu",
"age": 17
}
],
"list2": [
{
"name": "liuliu",
"age": 70
},
{
"name": "songba",
"age": 48
},
{
"name": "huangjiu",
"age": 12
}
]
}
在文件目录打开cmd命令窗口,运行 json-server data.json
成功后在浏览器访问http://localhost:3000页面
Resources项下的链接对应返回的数据接口
/list1 http://localhost:3000/list1
/list2 http://localhost:3000/list2