我正在尝试使用Jquery模板for循环从Json下面渲染值,但是没有从Json中获取任何值。以下是我的Json:
{
"CommentListClass":[
{
"Author":"Attis1",
"CommentText":"Really goo"
},
{
"Author":"joshar1",
"CommentText":"My picture"
},
}
我的Jquery模板是:
<script type="text/x-jsrender" id="tempRecentComments">
{{for List}}
<div class="item">
<div class="item-content">
<h3>{{:CommentListClass.Author}}</h3>
</div>
</div>
{{/for}}
</script>
答案 0 :(得分:2)
试试这个,
{{for CommentListClass}}
<div class="item">
<div class="item-content">
<h3>{{:Author}}</h3>
</div>
</div>
{{/for}}
使用数据,
[{
"CommentListClass": [{
"Author": "Test",
"CommentText": "Really goo"
}, {
"Author": "joshar1",
"CommentText": "My picture"
}]
}];
上进行测试