【发布时间】:2016-06-22 11:49:18
【问题描述】:
我有这个 json 数据:
{
"particles": {
"name": "particles",
"values": [
["35.5", 1466588408869],
["35.5", 1466589538531],
["45.5", 1466589577084]
]
},
"timestamps": {
"name": "timestamps",
"values": [
["144500", 1466588408870],
["144500", 1466589538531],
["144500", 1466589577084]
]
}
}
如何将其循环到下表中?
<table>
<tr>
<th>particles</th>
<th>timestamps</th>
</tr>
<tr>
<td>35.5</td>
<td>144500</td>
</tr>
<tr>
<td>35.5</td>
<td>144500</td>
</tr>
<tr>
<td>45.5</td>
<td>144500</td>
</tr>
</table>
我的尝试:
div.table-responsive
table.table.table-hover.table-bordered
thead
tr
each variable, i in dataset.data
if variable.name
th.text-center #{variable.name}
tbody
tr
each variable, i in dataset.data
if variable.values
td
each value, i in variable.values
p= value[0]
结果(不好):
<table class="table table-hover table-bordered">
<thead>
<tr>
<th class="text-center">particles</th>
<th class="text-center">timestamps</th>
</tr>
</thead>
<tbody>
<tr>
<td><p>35.5</p><p>35.5</p><p>45.5</p></td>
<td><p>144500</p><p>144500</p><p>144500</p></td>
</tr>
</tbody>
</table>
有什么想法吗?
【问题讨论】:
-
我们可以用jquery解决吗?
-
也许吧。为什么不:-)
标签: javascript html pug template-engine