我想在网格的下一行显示一个嵌套的 JSON 对象。我正在使用 Ember 和 mdc-layout-grid。
我的 JSON 数据如下:
data = [{
"amzOrderId": "403-8957866-2673902",
"financialEventType": "SHIPMENT",
"timestamp": 1570025882722,
"numOfItems": 1,
"nested": [{
"amzOrderId": "405-3430902-0842748",
"financialEventType": "SHIPMENT",
"timestamp": 1570025882722,
"numOfItems": 1}]},
{
"amzOrderId": "171-9021455-7043516",
"financialEventType": "SHIPMENT",
"timestamp": 15700258888722,
"numOfItems": 1,
"nested":null,
}]
我要渲染的 hbs 文件:
<li class="sales-list-row">
{{#mdc-layout-grid as |grid|}}
{{#grid.inner as |inner|}}
{{#inner.cell class="bought" span=2}}
<h3 class="bought__value">{{get data "numOfItems"}}</h3>
{{/inner.cell}}
{{#inner.cell class="purchased" span=2}}
<span class="purchased__text">Purchased</span>
<h3 class="purchased__value">{{format-date (get data "timestamp") "date"}}</h3>
{{/inner.cell}}
{{#inner.cell class="id" span=2}}
<h4 class="id__value">{{get data "amzOrderId"}}</h4>
{{/inner.cell}}
{{/grid.inner}}
{{/mdc-layout-grid}}
</li>
现在我想在下一行呈现“嵌套”对象值(如果存在,则移动到下一个数据[元素],以防嵌套为空)。我该如何解决这个问题?我尝试了几种方法,但它们不起作用。