https://developers.weixin.qq.com/miniprogram/dev/framework/release/
https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.onDiscovered.html
我用开发工具连接手机,真机调试。发现
res没有 messages 属性,res 的值是这个techs: (2) ["NFC-A", "MIFARE Classic"]
手机小米6,MIUI 10.4.2,安卓9
代码如下:
const app = getApp()
Page({
data: {
nfc: null
},
onLoad: function () {
var that = this;
that.setData({
nfc: wx.getNFCAdapter()
})
that.data.nfc.startDiscovery({
fail(err) {
console.log(err)
}
})
that.data.nfc.onDiscovered((res) => {
console.log(res)
})
},
onHide() {
if (this.data.nfc) {
this.data.nfc.stopDiscovery()
}
}
})
解决了吗?我的返回值里id为空,卡号怎么读?