Files
ys-app/src/uni_modules/read-nfc
2025-12-01 18:07:02 +08:00
..
2025-12-01 18:07:02 +08:00
2025-12-01 18:07:02 +08:00
2025-12-01 18:07:02 +08:00
2025-12-01 18:07:02 +08:00
2025-12-01 18:07:02 +08:00

read-nfc

插件示例

1、通过插件市场“使用 HBuilderX 导入示例项目”下载插件示例项目

2、通过插件市场“试用”导入插件到示例项目中

3、打包并运行自定义基座

使用了NFC的Android原生库需要打包使用自定义基座

引入插件对象

import * as nfc from "@/uni_modules/read-nfc";

调起NFC识别

data() {
	return {
		title: '读取NFC监听',
		nfcCode:''
	}
},
onLoad() {
    this.gotoNfcActivity();//调起NFC识别并监听回调
},
methods: {
	gotoNfcActivity() {
		let that=this;
		nfc.gotoNfcActivity(function(result){
			that.nfcCode=result.message;
			uni.showModal({
				title: '提示',
				content: result.message,
				confirmText:'继续',
				success: function (res) {
					if (res.confirm) {
						that.gotoNfcActivity();//继续识别
						console.log('用户点击继续!');
					} else if (res.cancel) {
						console.log('用户点击取消!');
					}
				}
			});
			
			console.log('NFC',result);
		});
	}
}