Uncaught ReferenceError: ChromeSamples is not defined at (index):24:1

问题描述 投票:0回答:1

测试 Web NFC 并遵循 GoogleChrome 在 Github 上给出的脚本示例时,尝试在 www.000webhost.com 上部署我的网站时出现错误。我该如何解决?

错误:

Uncaught ReferenceError: ChromeSamples is not defined
at (index):24:1

错误引用 index.html(请参阅 Github 链接上的完整脚本)文件以下行:

<script>
log = ChromeSamples.log;

if (!("NDEFReader" in window))
  ChromeSamples.setStatus("Web NFC is not available. Use Chrome on Android.");
</script>
javascript google-chrome nfc
1个回答
0
投票

解决方案: 必须将 output_helper.html 内容包含到以下 index.html 行中:

{% include output_helper.html initial_output_content=initial_output_content %}

为什么? 因为链接中的存储库使用 Jekyll(它是 Ruby 的模板引擎)并自动用 output_helper.html 内容填充此 index.html 行。如果您不使用 Jekyll,那么您必须手动插入链接内容。

Here 是一个存储库,其中包含在 Google chrome 中工作的 NFC 读写器。如果对您有帮助,请为存储库加注星标!

感谢@Phil 在评论中提供这个答案!

© www.soinside.com 2019 - 2024. All rights reserved.