怎么样解决了吗?
关于小程序nfc卡模拟中的wx.onHCEMessage(callback)附上官方文档https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/wx.getHCEState.html 根据官方文档的做法 我的code如下 [代码]console.log([代码][代码]'aa'[代码][代码])[代码][代码] [代码][代码]wx.getHCEState({[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'getHCEState'[代码] [代码]+ res.errCode,[代码][代码] [代码][代码]duration: 2000[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]const buffer = [代码][代码]new[代码] [代码]ArrayBuffer(1)[代码][代码] [代码][代码]const dataView = [代码][代码]new[代码] [代码]DataView(buffer)[代码][代码] [代码][代码]dataView.setUint8(0, 0)[代码][代码] [代码][代码]console.log(buffer)[代码][代码] [代码][代码]wx.startHCE({[代码][代码] [代码][代码]aid_list: [[代码][代码]'F223344556'[代码][代码]],[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码] [代码] [代码][代码]console.log([代码][代码]'startHCE'[代码][代码])[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'startHCE'[代码][代码],[代码][代码] [代码][代码]duration: 2000[代码][代码] [代码][代码]})[代码][代码] [代码][代码]wx.onHCEMessage([代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'onHCEMessage'[代码][代码],res)[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'onHCEMessage'[代码][代码],[代码][代码] [代码][代码]duration: 2000[代码][代码] [代码][代码]})[代码][代码] [代码][代码]if[代码] [代码](res.messageType === 1) {[代码] [代码] [代码][代码]console.log([代码][代码]'res.messageType === 1'[代码][代码]);[代码] [代码] [代码][代码]wx.sendHCEMessage({[代码][代码] [代码][代码]data: buffer,[代码][代码] [代码][代码]success:(res)=>{[代码][代码] [代码][代码]console.log([代码][代码]'sendHCEMessage'[代码][代码]+res)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail:(res)=>{[代码][代码] [代码][代码]console.log([代码][代码]'sendHCEMessage失败'[代码] [代码]+ res)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail(res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail(res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: res,[代码][代码] [代码][代码]duration: 2000[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码]以上代码执行结果如下 我把手机放到读卡器上了 没反应[图片] [代码]wx.onHCEMessage([代码][代码]function[代码][代码](res) { 这个函数一直不执行 没任何结果也不返回任何值 [代码] 请问这个是怎么模拟卡的
2021-11-01