AIo*_*Ion 9 javascript firebase
It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.
For the CDN builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):
https://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js
Run Code Online (Sandbox Code Playgroud)
它占用了我已经有限的控制台空间的一半:(
注意:我在html中使用firebase ..使用脚本标记.我没有使用这里解释的导入语法:类似的问题
如何阻止此警告?
Mar*_*nas 11
更清楚地回答这个问题,
你最有可能的是
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase.js"></script>
Run Code Online (Sandbox Code Playgroud)
因为这是Firebase通过"将Firebase添加到您的网络应用程序"屏幕为您提供的.
但是,这样做是导入所有Firebase模块.我不知道为什么Firebase将此作为生成的脚本,但您需要做的就是将-app添加到源代码,现在就是这样.
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>
Run Code Online (Sandbox Code Playgroud)
然后,对于您想要使用的Firebase的每个后续功能,您将需要添加另一个脚本行.例如,如果您想将云消息传递添加到您的Web应用程序,则只需要.
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-messaging.js"></script>
Run Code Online (Sandbox Code Playgroud)
您可以在Firebase中找到更多信息,包括完整的导入列表.
您的错误消息告诉您如何修复它……这部分就在这里:
For the CDN builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):
https://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js
Run Code Online (Sandbox Code Playgroud)
因此,如果您使用 Firebase 身份验证,您将有一个脚本标签请求https://www.gstatic.com/firebasejs/5.0.0/firebase-auth.js... 而对于 Firebase 数据库,您还将拥有另一个带有https://www.gstatic.com/firebasejs/5.0.0/firebase-database.js... 的脚本标签。对于您需要的 Firebase 的任何其他部分,只需遵循该模式即可。
| 归档时间: |
|
| 查看次数: |
10467 次 |
| 最近记录: |