使用VUEJS显示从Firebase到Web的图像
我是Vue的新手,所以我不知道做这件事的多种方法。我想在我的应用程序上显示图像,该图像存储在Firebase存储中。我在HTML部分中的标签中调用一个函数,该功能返回图像的URL。我能够在控制台中显示图像,但是当应该返回URL时,它会给我一个“找不到模块”错误。
html
<div>
<p> Image gallery:</p>
<img v-bind:src="getImgUrl()" >
</div>
vue方法
async getImgUrl() {
// Create a reference to the file we want to download
const storage = getStorage();
const stationsRef = ref(storage, 'stations/cal.jpg');
// Get the download URL
const imageurl = await getDownloadURL(stationsRef)
.then((url) => {
return (url);
})
console.log(imageurl)
return require(imageurl);
},
,这是它给出的错误:
Uncaught (in promise) Error: Cannot find module 'https://firebasestorage.googleapis.com/v0/b/rideservices-6a23d.appspot.com/o/stations%2Fcal.jpg?alt=media&token=d020eef5-88f3-4f64-aab0-fcf00d67bcd5'
at webpackEmptyContext (app.a802d1ae56e3977d.hot-update.js:40:10)
at Proxy.getImgUrl (serviceRequest.vue?b4a4:168:1)
如果我能获得帮助,这将非常有帮助。提前致谢!
I am new to Vue so I don't know many ways to do this. I want to display an image on my application which is stored in the Firebase storage. I am calling a function in the tag in the HTML part which returns the URL of the image. I am able to display the image in the console but it gives me a "Cannot find module" error when it is supposed to return the URL.
HTML
<div>
<p> Image gallery:</p>
<img v-bind:src="getImgUrl()" >
</div>
Vue Method
async getImgUrl() {
// Create a reference to the file we want to download
const storage = getStorage();
const stationsRef = ref(storage, 'stations/cal.jpg');
// Get the download URL
const imageurl = await getDownloadURL(stationsRef)
.then((url) => {
return (url);
})
console.log(imageurl)
return require(imageurl);
},
and this is the error that it gives:
Uncaught (in promise) Error: Cannot find module 'https://firebasestorage.googleapis.com/v0/b/rideservices-6a23d.appspot.com/o/stations%2Fcal.jpg?alt=media&token=d020eef5-88f3-4f64-aab0-fcf00d67bcd5'
at webpackEmptyContext (app.a802d1ae56e3977d.hot-update.js:40:10)
at Proxy.getImgUrl (serviceRequest.vue?b4a4:168:1)
It would be really helpful if I can get help on this. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论