[英]Get image from server side folder and display image in Vue
I'm trying to display image from public folder of my node api directory.我正在尝试从我的节点 api 目录的公共文件夹中显示图像。 I want to display image in front end vue file.
我想在前端 vue 文件中显示图像。 I don't know how to give source of image.
我不知道如何给出图像来源。
This is the directory.这是目录。 I want to display image
nodelogin.png
我想显示图像
nodelogin.png
I want to display these images.我想显示这些图像。
<img :src="myimage" alt="Logo" width="80" height="80" />
This is my template code.这是我的模板代码。
async created() {
this.myimage = await this.getImage();
},
methods: {
async getImage(){
return await 'http://localhost:4000/api/public/nodelogin.png';
}
}
But this code gives an error response.但是这段代码给出了错误响应。
Cannot GET /api/public/nodelogin.png
Actually I'm new to node and Vue So I'm not sure whether my logic is correct or not. Cannot GET /api/public/nodelogin.png
实际上我是 node 和 Vue 的新手所以我不确定我的逻辑是否正确。
Do I need to do something from my backend side?我需要从后端做些什么吗?
Just use the url '/nodelogin.png'
只需使用 url
'/nodelogin.png'
Thanks for your question posting.感谢您发布问题。
If you want see png, you should input url:如果要查看 png,则应输入 url:
http://localhost:4000/nodelogin.png
Good luck for your business.祝您生意兴隆。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.