- 微信小程序中怎么使用gb2312编码解码?
js代码 function analysis(hexString) { const byteArray = new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); // 使用TextDecoder解码字节数组为字符串 const decoder = new TextDecoder('gb2312'); const decodedString = decoder.decode(byteArray); return decodedString; } // // 输出结果字符串 console.log(analysis("d4c144363536353600000000")); //粤D65656 在微信小程序中使用不了TextDecoder,怎么办,有没有其他方法能把GB2312转成汉字
09-20 - 微信小程序中使用iconv-lite包引入报错?
npm install iconv-lite --save const iconv = require('iconv-lite'); // 假设你有一个GB2312编码的Buffer或Uint8Array类型的变量gb2312Data let gb2312Data = ...; // 这里应该是你的GB2312编码数据 // 使用iconv-lite将GB2312编码的数据转换为汉字 let utf8Data = iconv.decode(gb2312Data, 'gb2312'); console.log(utf8Data); // 输出转换后的汉字字符串 引入之后编译就报错 页面【pages/deviceDetection/deviceDetection]错误: Error: module 'miniprogram_npm/safer-buffer/buffer.js' is not defined, require args is 'buffer' at q (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1) at r (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1) at __REQUIRE__ (index.js?t=wechat&s=1726808096631&v=5578d0db45387fe60c6c624bc121c13e:20) at safer.js:77 at Object.func (safer.js:5) at __REQUIRE__ (index.js?t=wechat&s=1726808096631&v=5578d0db45387fe60c6c624bc121c13e:40) at safer.js:77 at safer.js:77 at WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1 at p.runWith (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1)(env: Windows,mp,1.06.2405020; lib: 3.5.6) (anonymous) @ VM3865:11 Error: module 'miniprogram_npm/safer-buffer/buffer.js' is not defined, require args is 'buffer' at q (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1) at r (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1) at __REQUIRE__ (index.js?t=wechat&s=1726808096631&v=5578d0db45387fe60c6c624bc121c13e:20) at safer.js:77 at Object.func (safer.js:5) at __REQUIRE__ (index.js?t=wechat&s=1726808096631&v=5578d0db45387fe60c6c624bc121c13e:40) at safer.js:77 at safer.js:77 at WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1 at p.runWith (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1)(env: Windows,mp,1.06.2405020; lib: 3.5.6) Component is not found in path "wx://not-found".(env: Windows,mp,1.06.2405020; lib: 3.5.6)[图片]
09-20 - img组件图片问题bug
{{list.icon}}是一个地址路径 timestamp: Date.now(), //时间戳 在开发者里面配置了访问这个路径的白名单,当开发者工具运行这段代码就会报错。 我的小程序运行页面: pages/dealwith/addVehicle/addVehicle [渲染层网络层错误] Failed to load local image resource /pages/dealwith/addVehicle/ the server responded with a status of 404 (HTTP/1.1 404 Not Found) (env: Windows,mp,1.06.2404301; lib: 3.4.6) [图片]
06-21 - 无法注销公众号?
[图片]
06-11 - 为什么微信小程序切到后台会自动断开webSocket连接?
想实现一些实时通信功能,小程序切换到后台会自动断开webSocket连接,这是为什么,为什么要这样设计?
2023-08-16 - 广告组件怎么总是报错MiniProgramError {"errMsg":"no ad?
onLoad() { if (wx.createRewardedVideoAd) { this.rewardedVideoAd = wx.createRewardedVideoAd({ adUnitId: 'adunit-3c082383f00e9f2d' }) this.rewardedVideoAd.onLoad(() => { console.log('onLoad event emit') console.log('激励视频 广告加载成功') }) this.rewardedVideoAd.onError((err) => { console.log('拉取失败onError event emit', err) }) this.rewardedVideoAd.onClose((res) => { console.log('监听用户onClose event emit', res) }) this.rewardedVideoAd.show().then(() => console.log('激励视频 广告显示')) } } [图片] 项目是uniapp框架编译到微信小程序,广告组件因为uniapp官方不支持个人类型的广告接入,只能使用微信原生的写法wx.xxx,加载激励广告会报错。 页面加载就触发了这个报错 [图片] 关闭广告页会触发报错 [图片]
2023-07-21 - 微信个人公众号菜单栏报错48001
https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html { "button": [ { "name": "关于我们", "sub_button": [ { "type": "click", "name": "激活听歌", "key": "激活听歌" } ] } ] } 一直报错也看不出来是哪里有问题 200 OKConnection: keep-aliveDate: Thu, 20 Jul 2023 08:46:01 GMTContent-Type: application/json; encoding=utf-8Content-Length: 77{ "errcode": 48001, "errmsg": "api unauthorized rid: 64b8f449-3f3d2ebf-65f8753c" } [图片]
2023-07-20