简体   繁体   English

从服务器端文件夹获取图像并在 Vue 中显示图像

[英]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

这是目录。我想显示图像 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.

相关问题 如何以角度显示图像(在服务器端上载的文件夹中上传的图像和angularjs在其他服务器中工作)? - How to display image in angular(image uploded in server side uploads folder and angularjs is working in different server)? React_Display Image 从服务器端到客户端 - React_Display Image from server side into Client 从静态文件夹获取图像文件并将其显示在客户端应用程序中 - GET image files from static folder and display them in client app 从后端文件夹获取图像并在前端显示(React 和 Node) - Get image from Backend folder and display it in frontend (React and Node) FabricJS从服务器端的路径加载图像? - FabricJS load image from path at server side? 如何使用node.js从目录获取图像并将其发送到客户端以在Android应用程序上显示 - How to get image from directory with node.js and send it to the client side to display on android app 如何将jpeg文件从服务器上的文件夹发送到客户端并在Image元素中显示它? - How to Send a jpeg File from a Folder on Server to the Client and Display It in an Image element? 来自 express static 文件夹的图像未出现在客户端 - Image from express static folder is not appearing on the client side PNG图像的$áa$ I $ I $$…-Vue / Node / Express |如何显示从Node.js服务器发送到客户端Vue应用程序的图像? - $�a �$I��"I�$�… for PNG image - Vue/Node/Express | How do I display an image that I sent from a Node.js server to a client Vue app? 反应和表达:从公共文件夹中获取图像 - react and express: get image from public folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM