解决前端获取后端gbk文件导致中文乱码的问题

let url = 'xxx'
   axios
    .get(url, {
     responseType: 'blob',
    })
    .then(res => {
     let reader = new FileReader()
     reader.readAsText(res, 'GBK')
     reader.onload = e => {
      let data = JSON.parse(reader.result)
      console.log(data)
     }
    })
    .catch(e => {
     console.log(e)
    })

参考地址:https://www.cnblogs.com/bjhl/articles/10514038.html

posted @ 2024-06-05 09:38  yw3692582  阅读(27)  评论(0编辑  收藏  举报