<script>
then response
then data
优势:不用引用jq
fetch('./00 data.json')
提供一个参数用来指明想
fetch()
到的资源路径,然后返回一个包含响应结果的 promise(一个 Response
对象) .then(function(response) {
// resolve
console.log(response);
return response.json();
})
.then(function(data) {
console.log(data);
})
.catch(function(){
仅当网络故障时或请求被阻止时,才会标记为 reject
reject
});
</script>