针对atob btoa 对中文处理乱码或者不成功

391 阅读1分钟
decodeURIComponent(atob(btoa(encodeURIComponent("测试"))))

核心思想就是 先把json的字符串或者字符串编码,然后转为base64,再转回来再进行解码。

atob

是把字符串转为base64

btoa在把base64变成字符串