Fetch 网络请求
1.大概格式:
1 fetch("url",{}).then(function(response){ 2 console.log(repsonse.status);//http code 3 console.log(repsonse.statusText);//text 4 console.log(repsonse.ok);//boolean 5 })
fetch的返回是promise类型:
- arrayBuffer();
- blob();
- json();
- text();
- fromData();
如何改变返回的数据类型
1 fecth("").then(function(response){ 2 return response.json().then(function(json){ 3 //然后进行dom渲染 4 }) 5 6 7 8 })

浙公网安备 33010602011771号