3 回答
TA贡献1829条经验 获得超4个赞
$.ajax({
type:"GET",
url:"json/index.json",
async:true,
success: function (data) {
let list = '';
for (let i in data.data) {
//子节点循环
let pic = '';
let line = data.data[i].picurl
for (let x in line) {
pic += `<div class="image"><img src="${data.data[i].picurl[x].pic}"></div>`
}
list += `<li>
<a href="javascript:">
<div class="list_top flex">
<div class="head-time f1">${data.data[i].time}</div>
<div class="head-true_false f1">${data.data[i].state}</div>
</div>
<div class="content_img">${pic}</div>
<div class="footer">
<div class="number_monet">共${data.data[i].numbers}件商品,实付<span class="money">¥${data.data[i].money}</span></div>
<div class="fd">
<object><a href="javascript:" class="btn">${data.data[i].btn}</a></object>
</div>
</div>
</a>
</li>`;
}
}
$('.list_ul').prepend(list)
});
TA贡献1772条经验 获得超5个赞
应该把第二个循环放到第一个循环的里面。
for (let i in data.data) {
y = i;
...
let line = ...
for (let x in line)
}
添加回答
举报