请问为什么我的template不起作用?

查尔斯欢 2017-06-16 10:03:11
后台返回的数据格式是这样的:

{
"has_next": true,
"result": [
{
"pk": 36424868,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-15T14:00:40",
"destination": "online",
"messagetype": "full",
"timespent": 19000,
"starttime": "2017-06-15T14:00:37",
"fullindexversion": "20170615140021",
"action": "switch",
"path": "adlocationqu/full/20170615140021",
"indexcount": 46963,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 36361159,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-14T14:00:39",
"destination": "online",
"messagetype": "full",
"timespent": 18000,
"starttime": "2017-06-14T14:00:36",
"fullindexversion": "20170614140021",
"action": "switch",
"path": "adlocationqu/full/20170614140021",
"indexcount": 46959,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 36296869,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-13T14:00:39",
"destination": "online",
"messagetype": "full",
"timespent": 18000,
"starttime": "2017-06-13T14:00:36",
"fullindexversion": "20170613140021",
"action": "switch",
"path": "adlocationqu/full/20170613140021",
"indexcount": 46940,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 36230950,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-12T14:00:39",
"destination": "online",
"messagetype": "full",
"timespent": 19000,
"starttime": "2017-06-12T14:00:36",
"fullindexversion": "20170612140020",
"action": "switch",
"path": "adlocationqu/full/20170612140020",
"indexcount": 46938,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 36167347,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-11T14:00:39",
"destination": "online",
"messagetype": "full",
"timespent": 18000,
"starttime": "2017-06-11T14:00:36",
"fullindexversion": "20170611140021",
"action": "switch",
"path": "adlocationqu/full/20170611140021",
"indexcount": 46935,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 36104302,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-10T14:00:40",
"destination": "online",
"messagetype": "full",
"timespent": 20000,
"starttime": "2017-06-10T14:00:36",
"fullindexversion": "20170610140020",
"action": "switch",
"path": "adlocationqu/full/20170610140020",
"indexcount": 46935,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 36039231,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-09T14:00:39",
"destination": "online",
"messagetype": "full",
"timespent": 18000,
"starttime": "2017-06-09T14:00:36",
"fullindexversion": "20170609140021",
"action": "switch",
"path": "adlocationqu/full/20170609140021",
"indexcount": 46924,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 35972028,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-08T14:00:39",
"destination": "online",
"messagetype": "full",
"timespent": 18000,
"starttime": "2017-06-08T14:00:36",
"fullindexversion": "20170608140021",
"action": "switch",
"path": "adlocationqu/full/20170608140021",
"indexcount": 46942,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 35905584,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-07T14:00:39",
"destination": "online",
"messagetype": "full",
"timespent": 19000,
"starttime": "2017-06-07T14:00:36",
"fullindexversion": "20170607140020",
"action": "switch",
"path": "adlocationqu/full/20170607140020",
"indexcount": 46938,
"extrainfo": "",
"indexsize": 0
}
},
{
"pk": 35837976,
"model": "searchapps.artsindexmessage",
"fields": {
"serialid": "",
"appname": "adlocationqu",
"addtime": "2017-06-06T14:00:39",
"destination": "online",
"messagetype": "full",
"timespent": 19000,
"starttime": "2017-06-06T14:00:36",
"fullindexversion": "20170606140020",
"action": "switch",
"path": "adlocationqu/full/20170606140020",
"indexcount": 46936,
"extrainfo": "",
"indexsize": 0
}
}
]
}

我的代码是这样的:

$.ajax('/application/indexhistory?appName=' + '${appName}' + '&page=' + page).done(function (data) {
list = _(data.result).map(function (record) {
record.fields.addtime_display = record.fields.addtime.replace('T', ' ');
if(type == 'full'){
record.fields.version = record.fields.fullindexversion;
}
else{
record.fields.version = record.fields.serialid;
}
return _.template('<tr>'
+ '<td><%= version %></td>'
+ '<td><%= addtime_display %></td>'
+ '<td class="text-right time-spent"><%= timespent %></td>'
+ '<td class="text-right"><%= indexcount %></td>'
+ '</tr>', record.fields);
});
$('#full-history').html('<p> aaa' + list + '</p>');
setButtonState(data, page);
});

不能正确的填充list,请问是什么原因?这个写法我是从一个别人的网站源码学的,不知道是不是有什么坑?
...全文
242 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
上海程序员3 2017-06-19
  • 打赏
  • 举报
回复
你没有看到吗,你把一个}写成了]

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧