我有以下几点:
db.collection("users")
.where("activated", "==", 0)
.get()
.then(snap => {
snap.forEach(doc => {
if (String(doc.data().profileURL) != String(defaultImageUrl)) {
var r = document.getElementById('userTable').insertRow()
r.insertCell(1).innerHTML = doc.data().age
var storageRef = firebase.storage().ref();
var temp_photo = storageRef.child('avatar/'+doc.data().profileURL+'/')
temp_photo.getDownloadURL().then(downloadURL => {
console.log("log here -> " + downloadURL);
var y = r.insertCell(2).innerHTML = '<img src="'+downloadURL+'" width="50" height="50" />';
})
}
}
}//closing braces might be off but the rest of the code works, just to this purpose
});
});
所有数据显示正确,但图像不显示,应用程序崩溃
[错误]错误:无法实例化Firebase-store-请务必先加载fire base-app. js。(匿名函数)(fire base-store.js:1:39246)(匿名函数)(fire base-store.js:1:165)全局代码(fire base-store.js:1:188)[错误]未处理的Promise Reject:TypeError:firebase.storage不是函数。(在'firebase.storage()'中,'firebase.storage'是未定义的)(匿名函数)(toActivate. js:39)(匿名函数)(fire base-firestore.js:1:278233)(匿名函数)(fire base-firestore.js:1:64792)(匿名函数)(fire base-firestore.js:1:58068)(匿名函数)(fire base-firestore.js:1:58062)(匿名函数)(fire base-firestore.js:1:58062)(匿名函数)(fire base-firestore.js:1:58062)(匿名函数)(fire base-firestore.js:1:64769)(匿名函数)(fire base-firestore.js:1:278214)(匿名函数)(toActivate.js:20)
在我的html中,我确实有存储脚本:
<script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.15.5/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.2.3/firebase-storage.js"></script>
您的Firebase脚本的版本需要全部匹配。您的Firebase存储与fire base-app不匹配。根据发行说明,最新版本是7.23.0。