关于fetch网络请求
fetch也是内置的一种发送网络请求的方法,它和xhr的性质一样式window自带的。优势在于:可以不使用第三方的请求库就可以进行网络请求。fetch('/api/search/user2?q=${keyword}').then(res=>{ console.log("联系服务器成功了") //这里的 res.json()返回的是一个promise对象 return res.json()}, //error=>{ //console.log("联系服务器失败了",.
原创
2021-07-13 23:26:22 ·
294 阅读 ·
0 评论