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

Get image from server side folder and display image in Vue

我正在尝试显示节点 api 目录的 public 文件夹中的图像。我想在前端 vue 文件中显示图像。不知道怎么给图片来源

这是目录。我要显示图片 nodelogin.png

我想显示这些图片。

    <img :src="myimage" alt="Logo" width="80" height="80" />

这是我的模板代码。

     async created() {
             this.myimage = await this.getImage();
         },
     methods: {
             async getImage(){
                 return await 'http://localhost:4000/api/public/nodelogin.png';
             }
          }

但是这段代码给出了错误响应。 Cannot GET /api/public/nodelogin.png 实际上我是 node 和 Vue 的新手所以我不确定确定我的逻辑是否正确。

我需要从后端做些什么吗?

只需使用 url '/nodelogin.png'

感谢您发帖提问。

如果你想看png,你应该输入url :

http://localhost:4000/nodelogin.png

祝您生意兴隆。