全部引入 json-server
配置地址github
https://github.com/typicode/json-server
https://github.com/axios/axios#table-of-contentsaxios
npm install -g json-server
启动 json server
json-server --watch db.json
代码
//获取按钮组
var btns = document.querySelectorAll('button');
//获取所有数据
btns[0].onclick =function(){
axios({
// 默认值 get 不区分大小写
method:'get',
url:"http://localhost:3000/posts"
}).then((res)=>{