前端技术-ES6(10)
promise-async await
function ajax(url){
return new Promise(function(resolve, reject){
var xhr = new XMLHttpRequest();
xhr.open(‘GET’,url)
xhr.responseType = ‘json’
xhr.onload = function(){
if(this.status === 200){
resolve(this.response)
}else{
reject(new E
原创
2020-07-26 22:36:55 ·
70 阅读 ·
0 评论