我有一个如下数组:
quotation: [{
"dimension" : 0,
"currency": "RMB",
"quantity": "100",
"price": "3",
"factory": "rx"},
{
"dimension" : 0,
"currency": "RMB",
"quantity": "200",
"price": "4",
"factory": "rx"},
{
"dimension" : 1,
"currency": "RMB",
"quantity": "100",
"price": "3",
"factory": "rx"},
{
"dimension" : 1,
"currency": "RMB",
"quantity": "200",
"price": "5",
"factory": "rx"},
{
"dimension" : 0,
"currency": "RMB",
"quantity": "100",
"price": "1.2",
"factory": "hsf"},
{
"dimension" : 0,
"currency": "RMB",
"quantity": "200",
"price": "2.4",
"factory": "hsf"},
{
"dimension" : 1,
"currency": "RMB",
"quantity": "100",
"price": "3",
"factory": "hsf"},
{
"dimension" : 1,
"currency": "RMB",
"quantity": "200",
"price": "4.5",
"factory": "hsf"}]
我应该如何使用ejs变成下表?
<table>
<tr>
<th>Dimension</th><th>Quantity</th><th>Factory: rx</th><th>Factory: hsf</th>
</tr>
<tr>
<td>0</td><td>100</td><td>3</td><td>1.2</td>
</tr>
<tr>
<td>0</td><td>200</td><td>4</td><td>2.4</td>
</tr>
<tr>
<td>1</td><td>100</td><td>3</td><td>3</td>
</tr>
<tr>
<td>1</td><td>200</td><td>5</td><td>4.5</td>
</tr>
</table>
我必须确保价格来自正确的工厂。如果 html 允许我逐列定义表格,我认为这个问题很容易。但是 html table 只允许我按行执行。
非常感谢您的帮助。