无法加载文件/../firebase.js...。编码不是UTF-8

Art*_*iom 5 google-chrome-extension

描述您的环境:操作系统版本:mac os Firebase SDK版本:4.8.1 Firebase产品:数据库

描述问题:浏览器显示错误当我尝试将firebase.js添加到chrome扩展名时:无法加载文件/../firebase.js...。编码不是UTF-8。我尝试将其转换为utf-8,但浏览器仍然显示错误

重现步骤:使用https://www.gstatic.com/firebasejs/4.8.1/firebase.js下载firebase.js 将firebase.js添加到chrome扩展包中在chrome浏览器中启用开发人员模式在chrome浏览器中加载扩展

Rey*_*cia 1

我建议检查 github 中的官方Firebase Chrome 扩展示例以及Power your Chrome Extension with Firebase

这可能是您正在寻找的 manifest.json 的一部分:

"content_security_policy": "script-src 'self' https://cdn.firebase.com https://*.firebaseio.com https://*.firebaseio-demo.com; object-src 'self'",
Run Code Online (Sandbox Code Playgroud)

您应该可以开始将 Firebase 添加到您的 Chrome 扩展程序中。

附加示例:Chrome 扩展中使用 Google 登录的 Firebase Auth

  • 你好。谢谢。在示例中,我看到 firebase 仅使用background.htm(或background.js)。但我不明白如何在内容脚本中使用 firebase sdk :( 找到了使用 chrome.runtime.sendMessage 等的唯一解决方案。 (3认同)