我完全是新手...
我有一些 JSON
{
"article": [
{
"id": "21",
"type": "news",
"title": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
"summary": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
"url": "http://www....",
"website": "www...",
"authors": [],
"images": [
{
"title": "",
"dateCreated": "",
"name": "",
"path": ""
}
]
},
{
"id": "22",
"type": "news",
"title": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
"summary": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
"url": "http://www....",
"website": "www...",
"authors": [],
"images": [
{
"title": "",
"dateCreated": "",
"name": "",
"path": ""
}
]
},
{
"id": "23",
"type": "news",
"title": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
"summary": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
"url": "http://www....",
"website": "www...",
"authors": [],
"images": [
{
"title": "",
"dateCreated": "",
"name": "",
"path": ""
}
]
}
]
}
这个 JSON 有超过 3 个元素。我不知道如何按这样的顺序模板 2,3,1,4,5,6,7,8,...
如何使用json循环一次模板,并将属性值放在我的html标签中?
我希望有
<ul>
<li>
<img scr="path to object 2">
<a href="path to object 2">title of object 2</a>
</li>
<li>
<img scr="path to object 3">
<a href="path to object 3">title of object 3</a>
</li>
<li>
<img scr="path to object 1">
<a href="path to object 1">title of object 1</a>
</li>
<li>
<img scr="path to object 4">
<a href="path to object 4">title of object 4</a>
</li>
<li>
<img scr="path to object 5">
<a href="path to object 5">title of object 5</a>
</li>
...
<li>
<img scr="path to object n">
<a href="path to object n">title of object n</a>
</li>
</ul>
有什么建议吗?