fetch('请求网址',
{
method: 'GET|POST',
headers: {
'Content-Type': 'application/json'
// 'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify(data),
credentials: 'include'
})
.then(response => response.blob())
.then(data => {
let reader = new FileReader();
reader.onload = () => {
let text = reader.result;
console.log(text);
}
reader.readAsText(data, 'GBK');
})
.catch(error => {
console.log(error);
});
javascript使用fetch模拟请求响应内容GBK中文汉字乱码
于 2022-05-12 17:04:55 首次发布