【发布时间】:2019-08-02 21:11:13
【问题描述】:
怎么样,我试着咨询一下 NodeJs、Mysql 和 Handlebars。 查询的结果我没有问题。 BD中的表格如下。
水果桌
Id fruit
1 Apple
2 Mango
3 Strawberry
您进行查询的文件
Fruit.js
router.get('/', isLoggedIn, async (req, res) => {
const fruitAll = await db.query('SELECT * FROM fruit ’);
res.render(‘fruit’, {fruitAll});
});
我执行视图的文件如下。
List.hbs
{{#each fruitAll}}
<div class="container p-4">
<table border="1">
<tr>
<th>{{fruit}}</th>
</tr>
<tr>
<th>Example 1</th>
<th>Example 2</th>
<th>Example 3</th>
</tr>
</table>
</div>
{{/each}}
结果如下:
--------------
Apple
--------------
Example 1
--------------
Mango
--------------
Example 2
--------------
Strawberry
--------------
Example 3
--------------
我想要的是如何水平放置水果。我的意思是这样。
______________________________
|Apple |Mango | Strawberry|
_______________________________
|Example1|Example2| Example3 |
–––––––––––––––––––––––––––––––
【问题讨论】:
标签: mysql node.js handlebars.js