javascript - 为什么我的 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 的链接,但它无法描绘图片: 代码创建的表
我知道图片的名称是正确的,因为我打印了控制台记录并且它显示了正确的名称: 控制台日志
有人可以向我解释为什么 PNG 没有显示在桌子上吗?
解决方案
推荐阅读
- laravel - 3张表之间的雄辩关系问题
- reactjs - 如何在内部使用异步函数和 setState 测试 useEffect
- arrays - 使用 Vue 将数组数据发送到 laravel 控制器
- python - 在 python 列表中查找浮点数
- c# - 如何从根 GameObject 开始查找 GameObject(层次结构中的较低层)?
- javascript - 带break的这个do while循环发生了什么?
- python - 如果 python 中列的 len() 小于 10,则跳过整行
- javascript - 如何将 Javascript 代码放入 React 的组件中?
- python - 使用 {x,y} 坐标而不是余弦定律求三角形的角度
- asp.net-mvc - ASPNET MVC - 将所有 URL 子文件夹路由到单个控制器