【发布时间】:2021-07-02 15:17:55
【问题描述】:
我正在从 firestore 获取图像位置,并希望使用 v-bind:src 显示图像。您可以在下面找到我的代码:
<b-avatar v-bind:src = "profilepic" class="mr-5" size="8em"></b-avatar>
我的方法可以在下面找到:
export default {
data() {
return {
uid: "",
profilepic: "",
}
},
methods: {
getprofilepic() {
fb.storage().ref('users/' + this.uid + '/profile.jpg').getDownloadURL().then(imgURL => {
this.profilepic = imgURL;
alert(this.profilepic); // shows the correct path
})
},
}
created() {
this.uid = fb.auth().currentUser.uid;
this.getprofilepic();
}
}
我确信 this.profilepic 存储了正确的路径,就好像我要手动输入路径一样,它会显示出来。我怀疑在路径之前加载的页面可以从 Firestore 中检索。我该如何解决这个问题?提前谢谢你。
我已尝试将路径直接硬编码到数据,它工作正常。代码如下:
data() {
return {
uid: "",
profilepic: "*my firebase storage path*",
}
},
我不太确定为什么它仍然没有显示
【问题讨论】:
标签: firebase vue.js google-cloud-firestore