请求axios方法
1:
fetch('./01data.json', {})
//固定格式
.then(function (response) {
//resolve 成功
console.log(response);
return response.json();
})
//获取数据
.then(function (data) { //将获取到的数据放在data中
console.log(data);
})
//出错
.catch(function () {
//reject 失败
})
2:
axios.get("./01data.json", {
// Headers:{ //请求头 进行伪装
// },
params: { //params参数
id: 1001
}
})
.then(function (response) {
console.log(response.data) //数据
})
.catch(function (err) {
console.log(err)
})

浙公网安备 33010602011771号