路过。解决办法:全局监听,自己封装onNfcDiscovered和offNfcDiscovered
NFCAdapter.offDiscovered()调用无法取消监听?[图片] [图片] 按照官方的NFC使用流程,第一次操作一切正常。但是当进入其他页面时, 执行wx.getNFCAdapter()后再执行nfcAdapter.onDiscovered()函数, 会发现onDiscovered会重复执行上一个页面的onDiscovered。依此类推,在后续的使用中,总会调用之前的。希望平台给出示例,怎么通过NFCAdapter.offDiscovered取消监听。 已在社区发现多个社友提出该问题,还望平台给予重视,优化使用文档!
04-152024/3/26 依然闪退
微信小程序VKSession.runOCR启动闪退const session = wx.createVKSession({ track: { OCR: { mode: 2 } // mode: 1 - 使用摄像头;2 - 手动传入图像 }, version: 'v1' }); // 静态图片检测模式下,每调一次 runOCR 接口就会触发一次 updateAnchors 事件 session.on('updateAnchors', (anchors) => { uni.showToast({ icon: 'none', title: ''.concat(anchors.map((anchor) => anchor.text)) }); console.log('anchors.text', ''.concat(anchors.map((anchor) => anchor.text))); }); // 需要调用一次 start 以启动 session.start((errno) => { if (errno) { // 如果失败,将返回 errno console.log(errno, '检测失败'); } else { // 否则,返回null,表示成功 uni.showToast({ icon: 'none', title: '检测启动中' }); session.runOCR({ frameBuffer: arrayBuffer, // 图片 ArrayBuffer 数据。待检测图像的像素点数据,每四项表示一个像素点的 RGBA width: that.ocrImg.width, // 图像宽度 height: that.ocrImg.height // 图像高度 }); } }); },
2024-03-26同样闪退 const session = wx.createVKSession({ track: { OCR: { mode: 2 } // mode: 1 - 使用摄像头;2 - 手动传入图像 }, }) // 静态图片检测模式下,每调一次 runOCR 接口就会触发一次 updateAnchors 事件 session.on('updateAnchors', anchors => { console.log('anchors.text', anchors) }) // 需要调用一次 start 以启动 session.start(errno => { if (errno) { // 如果失败,将返回 errno } else { // 否则,返回null,表示成功 session.runOCR({ frameBuffer, width, // 图像宽度 height, // 图像高度 }) } })
VKSession.runOCR拿不到返回值,安卓端闪退https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.runOCR.html const version = wx.isVKSupport('v2') ? 'v2' : (wx.isVKSupport('v1') ? 'v1' : ''); if (version) { const session = wx.createVKSession({ version: version, track: { plane: {mode: 3}, OCR: { mode: 2 } // mode: 1 - 使用摄像头;2 - 手动传入图像 }, }); session.start(errno => { if (errno) { } else { session.runOCR({ frameBuffer:imgData.data.buffer, width: imgData.width, height: imgData.height }) } }); session.on('addAnchors', anchors => { console.log("anchor add", anchors); }) session.on('updateAnchors', anchors => { console.log("anchor updateAnchors", anchors); }); session.on('removeAnchors', anchors => { console.log('anchor remove', anchors); })
2024-03-26真机调试环境 2024/3/26 依然为null
wx.createOffscreenCanvas返回null?onLoad() { const canvas = wx.createOffscreenCanvas({ type: '2d', width: 300, height: 150 }) console.log(canvas) } 打印出来是null
2024-03-26