NFC tag has not been discovered什么原因?
const app = getApp()
Page({
nfc: null,
onLoad: function () {
const nfc = wx.getNFCAdapter()
this.nfc = nfc
function discoverHandler(res) {
console.log("discoverHandler")
console.log(res)
if (res.techs.includes("NFC-V")) {
const nfcV = nfc.getNfcV()
nfcV.connect({
complete(res) {
console.log('res:', res)
}
})
// nfcV.transceive({
// data: new ArrayBuffer(0),
// complete(res) {
// console.log('res:', res)
// }
// })
return
}
}
nfc.onDiscovered(discoverHandler)
nfc.startDiscovery({
success(res){
console.log(res)
},
fail(err) {
console.log('failed to discover:', err)
}
})
},
onHide() {
if (this.nfc) {
this.nfc.stopDiscovery()
}
}
})
同一台手机,使用app可以正常写入。但是使用小程序后就是报{errMsg: "connect:fail:NFC tag has not been discovered", errCode: 13013}