11.23
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
//第一个then返回的是response
//第二个then返回的是data
fetch('./00data.json')
.then(function (response) {
//resolve
//console.log(response) //显示判断是否正确
return response.json(); //固定的
})
.then(function (data) {
console.log(data);
})
.catch(function () {// catch 出错
//reject
})
</script>
</head>
<body>
</body>
</html>
axios
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./axios.min.js"></script>
<script>
// 参数 params
//数据 .data
axios.get("./00data.json",{
// Headers:{ //Headers请求头
// },
params:{
id:1001
}
})
.then(function(response){
console.log(response.data)
})
.catch(function(err){
console.log(err);
})
</script>
</head>
<body>
</body>
</html>

浙公网安备 33010602011771号