大家好,我的开源项目PakePlus可以将网页/Vue/React项目打包为桌面/手机应用并且小于5M只需几分钟,官网地址:pakeplus.com
有些接口返回的结果中编码格式竟然是GBK编码,导致结果可能出现中文乱码:
所以需要将响应结果使用GBK解码:
const response = await fetch('http://接口地址')
const buffer = await response.arrayBuffer()
// const data = new TextDecoder('utf-8').decode(buffer)
const text = new TextDecoder('gbk').decode(buffer)
console.log('text', text)