【问题标题】:displaying images in express js在 express js 中显示图像
【发布时间】:2014-02-26 05:41:18
【问题描述】:

下面,IMG标签显示get/user/(%27./files/%27)404

我如何使它看起来在正确的位置?

玉文件:

block content
    h1.
        #{user.name}
    ul
        li Email:   #{user.email}
        li Phone:   #{user.phone}
        li user ID: #{user._id}
        li <img src=('./files/' + user.name + '.png')/>

我尝试将以下内容添加到 app.js

app.get('./files/*:path', function(req, res) {
    res.sendfile(path.resolve(req.params.path))
});

没有变化。

【问题讨论】:

    标签: html node.js pug


    【解决方案1】:

    在您的 Jade 模板中试试这个:

    li
        img(src='./files/' + user.name + '.png')
    

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 1970-01-01
      • 2013-07-19
      • 2021-09-28
      • 1970-01-01
      • 1970-01-01
      • 2020-10-14
      • 2021-07-31
      • 1970-01-01
      相关资源
      最近更新 更多