android读取nfc并粘贴到浏览器文本框


有没有一个应用程序可以读取nfc并将相同的信息直接粘贴到浏览器的文本框中?我会使用nfc标签在我的网络应用程序上登录用户。我试过一些应用程序,但我做不到。

谢谢

您可以在Android上使用Web NFC读取NFC标签。

document.querySelector("#scanButton").onclick = async () => {
const ndef = new NDEFReader();
// Prompt user to allow website to interact with NFC devices.
await ndef.scan();
// When user taps NFC tag, a `reading` event is fired.
ndef.onreading = (event) => {
// Assuming there's only one "text" record in the NDEF message.
const record = event.message.records[0];
const textDecoder = new TextDecoder(record.encoding);
const decodedData = textDecoder.decode(record.data);
// Paste `decodedData` in an `<input>` HTML element.
document.querySelector("input").value = decodedData;
};
};

希望它能有所帮助。

最新更新