【发布时间】:2018-12-31 19:12:07
【问题描述】:
我正在使用cordova + react js 作为实现 NFC(近场通信)的一部分,我下载了 phonegap-nfc 插件 但是当我尝试使用 phonegap 的 nfc 插件对象变量时,在我的一个 javascript 文件中抛出异常。喜欢(从'phonegap-nfc/www/phonegap-nfc'导入nfc;) 收到的错误是:
找不到模块:错误:无法解析 'D:\GIT\lockers-app-ret 中的 'cordova/exec' ail-wf_latest\node_modules\phonegap-nfc\www'
下面给出的相关代码
处理NFCPopup = () =>{ console.log("hello jb you are in NFC pop up...");
// Read NDEF formatted NFC Tags
nfc.addNdefListener (
(nfcEvent) =>{
var tag = nfcEvent.tag,
ndefMessage = tag.ndefMessage;
// dump the raw json of the message
// note: real code will need to decode
// the payload from each record
alert(JSON.stringify(ndefMessage));
// assuming the first record in the message has
// a payload that can be converted to a string.
alert(nfc.bytesToString(ndefMessage[0].payload).substring(3));
},
() => { // success callback
alert("Waiting for NDEF tag");
},
(error) =>{ // error callback
alert("Error adding NDEF listener " + JSON.stringify(error));
}
);
}
【问题讨论】:
标签: javascript reactjs cordova phonegap-plugins