收藏
回答

你们确定这玩意好用?



  onLoadfunction () {

    const nfc = wx.getNFCAdapter()

    this.nfc = nfc

    console.log(nfc)




    function discoverHandler(res{




      if (res.techs.includes(nfc.tech.ndef)) {

        console.log(res.messages)

        const ndef = nfc.getNdef()

        ndef.writeNdefMessage({

          uris: [''],

          complete(res) {

            console.log('res:', res)

          }

        })

        return

      }

      console.log('res.techs',res.techs)

      try {

        if (res.techs.includes(nfc.tech.nfcA)) {




          const nfcA = nfc.getNFCA()

          nfcA.transceive({

            datanew ArrayBuffer(0),

            complete(res) {

              console.log('res:', res)

            }

          })

          return

        }

      } catch (error) {

        console.error(error)

      }

      try {

        if (res.techs.includes(nfc.tech.mifareClassic)) {




          const nfcA = nfc.getMifareClassic()

          nfcA.transceive({

            datanew ArrayBuffer(0),

            

            complete(res) {

              console.log('res:', res)

            }

          })

          return

        }

      } catch (error) {

        

      }

  

    }




    nfc.onDiscovered(discoverHandler)

    nfc.startDiscovery({

      success(e){

        console.log('success to discover:',e)

      },

      complete(e){

        console.log('complete to discover:',e)

      },

      fail(err) {

        console.log('failed to discover:', err)

      }

    })

  },







回答关注问题邀请回答
收藏

1 个回答

  • 社区技术运营专员-Jahozheng
    社区技术运营专员-Jahozheng
    08-08

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    08-08
    有用
    回复
登录 后发表内容