Has*_*aza 3 javascript firebase firebase-realtime-database
我在我的 html 中包含了这些 CDN:
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
<script src="StoreFeatured.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
这是商店的特色代码
var firebaseConfig = {
apiKey: "$$$$$$$",
authDomain: "$$$$$$",
databaseURL: "https://thegreatpcstore.firebaseio.com",
projectId: "thegreatpcstore",
storageBucket: "thegreatpcstore.appspot.com",
messagingSenderId: "302435893791",
appId: "$$$$$$$",
measurementId: "G-0GH3F41E5S"
};
firebase.initializeApp(firebaseConfig);
new function GetData()
{
firebase.database().ref('/Products/Motherboard/1').once('value').then(function (snapshot) {
//var Description = snapshot.val().Description;
var Name = snapshot.val().Name;
var Price = snapshot.val().Price;
var ImageStr = snapshot.val().ImageStr;
document.getElementById("Mi"+i).src=ImageStr;
document.getElementById("Mn"+i).innerHTML=Name;
document.getElementById("Mp"+i).innerHTML=Price;
}
)
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我收到这些错误:
> firebase-auth.js:206 Uncaught Error: Cannot find the firebase namespace; be sure to include firebase-app.js before this library.
at firebase-auth.js:206
at firebase-auth.js:206
at firebase-auth.js:206
>
> firebase-database.js:38 Uncaught Error: FIREBASE FATAL ERROR: Failed
> to register the Firebase Database Service (TypeError:
> firebase.INTERNAL.registerService is not a function)
> at dd (firebase-database.js:38)
> at firebase-database.js:245
> at firebase-database.js:245
>
> StoreFeatured.js:17 Uncaught TypeError: firebase.database is not a
> function
> at new GetData (StoreFeatured.js:17)
> at StoreFeatured.js:13
Run Code Online (Sandbox Code Playgroud)
getdata() 的第一行出现问题,我认为我在使用 cdn 时做错了...请帮忙
如果我删除 CDN,它会出现一个错误:
StoreFeatured.js:16 Uncaught TypeError: firebase.database is not a function
at new GetData (StoreFeatured.js:16)
at StoreFeatured.js:13
Run Code Online (Sandbox Code Playgroud)
将 firebase-auth 和 firebase-database 更新为以下版本:
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-database.js"></script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2054 次 |
| 最近记录: |