let that = this
let xhr = new XMLHttpRequest()
xhr.open('GET', 'https://xxx.com/api')
xhr.responseType = 'json'
xhr.send()
xhr.onload = function () {
that.loading = false
if (xhr.status === 200) {
let resp = xhr.response
console.log(resp)
} else {
console.log('Error')
}
};
vue解决跨域最简单的办法
于 2023-09-16 00:16:29 首次发布
本文详细描述了如何使用JavaScript的XMLHttpRequest对象发送GET请求到API并处理响应,包括设置响应类型、监听onload事件以及检查HTTP状态码。
https://weisizhushou.com

3215

被折叠的 条评论
为什么被折叠?



