微信小程序 textdecoder is not defined #vue3+ts+uniap项目解决方案

解决方案:

npm install --save utf8array2str
import utf8Array2Str from 'utf8array2str';

utf8Array2Str(new Uint8Array([104, 101, 108, 108, 111]));
// => hello

 

 
问题复现:
使用 const text = new TextDecoder('utf-8').decode(new Uint8Array(res.data)) ,虽然在微信开发者工具没问题,但进行真机调试就会出现“textdecoder is not defined”尝试各种,要么是中文乱码,要么真机也是不行。
 
 
posted @ 2024-04-10 22:47  小庄的blog  阅读(122)  评论(0编辑  收藏  举报