我正在尝试让 Web NFC 通过Web NFC API工作,但无法通过以下错误消息:NotAllowedError: NFC permission request denied.
我在 Windows 10 计算机上的 Chrome 89 Dev 上使用它,源代码在本地运行。
我也尝试过互联网上发布的示例,包括Google 示例,但它返回相同的错误。我并不担心它目前处于实验阶段,因为提到这一点确实表明它已经成功通过了必要的测试,包括权限。
我正在使用的 HTML/JS 代码如下,我已经阅读了规范点 9.3,但我无法理解将其编写为代码,因此是否有一个指导算法可以帮助解决这个问题这?
async function readTag() {
if ("NDEFReader" in window) {
const reader = new NDEFReader();
try {
await reader.scan();
reader.onreading = event => {
const decoder = new TextDecoder();
for (const record of event.message.records) {
consoleLog("Record type: " + record.recordType);
consoleLog("MIME type: " + record.mediaType);
consoleLog("=== data ===\n" + …Run Code Online (Sandbox Code Playgroud)