问题描述
我正在尝试从数据库创建一个表并将其拉到网站上,到目前为止,我已经成功地拉取和显示了文本数据,但是当涉及到图片时,我被卡住了。 我使用类中的这个函数从数据库中提取信息:
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)
}
})
<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 (将#修改为@)