微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么我的 png 没有出现在我的桌子上?

如何解决为什么我的 png 没有出现在我的桌子上?

我正在尝试从数据库创建一个表并将其拉到网站上,到目前为止,我已经成功地拉取和显示了文本数据,但是当涉及到图片时,我被卡住了。 我使用类中的这个函数数据库提取信息:

async all() {
        const sql = 'SELECT Photo,Title,Date_Time FROM articles;'
        const articles = await this.db.all(sql)     
        return articles
}

然后传递给路由器:

router.get('/',async ctx => {
    const articles = await new Articles(dbname)
    try {
        const records = await articles.all() //Assigned to the variable records over here
        console.log(records)
        ctx.hbs.records = records
        await ctx.render('newsIn',ctx.hbs)
    } catch(err) {
        ctx.hbs.error = err.message
        await ctx.render('error',ctx.hbs)
    }
})

它重新路由到使用以下 HTML 代码描绘数据的页面

        <main>
        <table>
        <tr><th>Photo</th><th>Title</th><th>Date</th></tr>
        {{#each records}}
            <tr>
                <td><img src="images/{{this.Photo}}" width="20" height="20"/></td>
                <td>{{this.Title}}</td>
                <td>{{this.Date_Time}}</td>
            </tr>
        {{/each}}
        </table>
        </main>

它甚至可以提取正确的信息,甚至是 png 的链接,但它无法描绘图片The Table that the code creates

我知道图片名称是正确的,因为我打印了控制台记录并且它显示了正确的名称The Console Log

谁能向我解释为什么 PNG 没有显示在桌子上?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。