我使用import { NfcvService } from 'cordova-nfcv-plugin/ionic2';
实现我的离子项目的NFC模块。
我一直犯这个错误, console error output
答案 0 :(得分:0)
仅用于建议确保已在应用程序模块和当前组件中导入了NFC,
这是一个例子
import {NfcvService} from 'cordova-nfc-plugin/ionic2';
@NgModule({
providers: [
NfcvService
]
})
export class AppModule {}
app.component.ts
import { NfcvService } from 'cordova-nfc-plugin/ionic2';
constructor(public nfcvService: NfcvService) {
nfcvService.addNdefListener();
}
ngOnInit() {
this.nfcvService.onTag().subscribe((tag) => {
//Avoid reading null tag on first call
if (tag) {
console.log('Found tag:', tag);
this.tag = tag; // here you can use variable further
}
});
}
希望它能解决您的问题。
有关更多参考,请访问此处的网站
https://github.com/valentiniljaz/cordova-nfc-plugin/blob/master/ionic2/readme.md