Mysql 水平排列<;th>;带有节点和把手的桌子标签
怎么样,我试着咨询一下NodeJs、Mysql和handlebar。 查询的结果我没有问题。 BD中的表格如下所示 水果桌Mysql 水平排列<;th>;带有节点和把手的桌子标签,mysql,node.js,handlebars.js,Mysql,Node.js,Handlebars.js,怎么样,我试着咨询一下NodeJs、Mysql和handlebar。 查询的结果我没有问题。 BD中的表格如下所示 水果桌 Id fruit 1 Apple 2 Mango 3 Strawberry 进行查询的文件 水果.js router.get('/', isLoggedIn, async (req, res) => { const fruitAll = await db.query('SELECT * FROM fruit ’); res.r
Id fruit
1 Apple
2 Mango
3 Strawberry
进行查询的文件
水果.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 |Mango | Strawberry|
_______________________________
|Example1|Example2| Example3 |
–––––––––––––––––––––––––––––––
它将是:
<div class="container p-4">
<table border="1">
<tr>
{{#each fruitAll}}
<th>{{fruit}}</th>
{{/each}}
</tr>
<tr>
<th>Example 1</th>
<th>Example 2</th>
<th>Example 3</th>
</tr>
</table>
</div>
{{{#每个水果}
{{水果}
{{/每个}}
例1
例2
例3
因为您需要更多的th
标记。在您的情况下,。
将被复制furtall.length
(在本例中为3)次
<div class="container p-4">
<table border="1">
<tr>
{{#each fruitAll}}
<th>{{fruit}}</th>
{{/each}}
</tr>
<tr>
<th>Example 1</th>
<th>Example 2</th>
<th>Example 3</th>
</tr>
</table>
</div>