无法获取foreach knockout.js中的最后一个索引
我无法在gsp页面中获取foreach内部的最后一个observableArray索引,如下所示无法获取foreach knockout.js中的最后一个索引,knockout.js,knockout-2.0,knockout-mvc,Knockout.js,Knockout 2.0,Knockout Mvc,我无法在gsp页面中获取foreach内部的最后一个observableArray索引,如下所示 <!-- ko foreach: $data.audienceInformation.IndivisualUsers --> <span data-bind="html:$index()"></span> //Here index is coming correctly <span data-bind="html:$last">&
<!-- ko foreach: $data.audienceInformation.IndivisualUsers -->
<span data-bind="html:$index()"></span> //Here index is coming correctly
<span data-bind="html:$last"></span> //i want last index here
<span data-bind="html:$data+','"></span>
<!-- /ko -->
//这里的索引是正确的
//我要最后一个索引
这是我的JSON数据
{
"AccountMessagesHistory": {
"audienceInformation": {
"Accounts": ["DHL"],
"IndivisualUsers": ["fashangxue8@163.com"]
},
"documentInformation": ["Name: ",
"Title: <p>aa</p>",
"Description: <p>aa</p>",
"Document Type: text",
"This document belongs (creator/last modifier) to: b2b:cpqadmin@compaq.com",
"This document is published for the language: en_US",
"This document was created on: Mon Mar 03 03:15:09 MST 2014",
"This document was last modified on: Mon Mar 03 03:15:09 MST 2014",
"This document is a text document",
"This document will be available from: Mon Mar 03 00:00:00 MST 2014",
"This document will be available until: Tue Mar 03 00:00:00 MST 2015",
"This document is available under message feature card"],
"documentHistory": ["User ID: b2b:cpqadmin@xyz.com Name: HP Admin,ITG Modified On: Mon Mar 03 03:15:09 MST 2014"]
}
}
{
“会计信息历史”:{
“听众信息”:{
“账户”:[“DHL”],
“个人”:[”fashangxue8@163.com"]
},
“文档信息”:[“名称:”,
“标题:aa”,
“说明:aa”,
“文档类型:文本”,
“此文档属于(创建者/最后修改者):b2b:cpqadmin@compaq.com",
“本文件发布的语言为:en_US”,
“本文件创建日期:2014年3月3日星期一03:15:09”,
“本文件上次修改日期:2014年3月3日星期一03:15:09”,
“此文档是文本文档”,
“本文件将于2014年3月3日星期一00:00:00 MST提供”,
“本文件有效期至:2015年3月3日星期二00:00:00 MST”,
“此文档在信息功能卡下提供”],
“documentHistory”:[“用户ID:b2b:cpqadmin@xyz.com名称:HP管理员,ITG修改日期:2014年3月3日星期一03:15:09 MST“]
}
}
使用数组的.length
代替$last
:
<span data-bind="text: ko.utils.unwrapObservable($parent.audienceInformation.IndivisualUsers).length - 1"></span>
使用数组的
.length
代替$last
:
<span data-bind="text: ko.utils.unwrapObservable($parent.audienceInformation.IndivisualUsers).length - 1"></span>
使用数组的
.length
代替$last
:
<span data-bind="text: ko.utils.unwrapObservable($parent.audienceInformation.IndivisualUsers).length - 1"></span>
使用数组的
.length
代替$last
:
<span data-bind="text: ko.utils.unwrapObservable($parent.audienceInformation.IndivisualUsers).length - 1"></span>
如果您使用的是knockout 2.1.0,您可以使用:
<span data-bind="text: $parent.audienceInformation.IndivisualUsers().length - 1"></span>
或
如果您使用的是knockout 2.1.0,您可以使用:
<span data-bind="text: $parent.audienceInformation.IndivisualUsers().length - 1"></span>
或
如果您使用的是knockout 2.1.0,您可以使用:
<span data-bind="text: $parent.audienceInformation.IndivisualUsers().length - 1"></span>
或
如果您使用的是knockout 2.1.0,您可以使用:
<span data-bind="text: $parent.audienceInformation.IndivisualUsers().length - 1"></span>
或
您确定使用的是淘汰赛2.0.0吗?我认为$index直到2.1.0才发布你确定你使用的是淘汰版2.0.0吗?我认为$index直到2.1.0才发布你确定你使用的是淘汰版2.0.0吗?我认为$index直到2.1.0才发布你确定你使用的是淘汰版2.0.0吗?我认为$index直到2.1.0才发布。要在ko 2.1.0中使用ko.unwrap
,你需要声明它if(typeof ko.unwrap==“undefined”){ko.unwrap=ko.utils.unwropbservable;}
你是对的,我把它改为ko.utils.unwropbservable
。要在ko 2.1.0中使用ko.unwrap
,你需要声明它if(typeof ko.unwrap=='undefined'){ko.unwrap=ko.utils.unwrapObservable;}
你说得对,我把它改成了ko.utils.unwrapObservable
。要在ko 2.1.0中使用ko.unwrap
,你需要声明它如果(typeof ko.unwrap=='undefined'){ko.unwrap=ko.utils.unwrapObservable;}
你是对的,我将其更改为ko.utils.unwrapObservable
。要在ko 2.1.0中使用ko.unwrap
,你需要声明它如果(typeof ko.unwrap=='undefined'){ko.unwrap=ko.utils.unwrapObservable};
你是对的,我将其更改为ko.utils.unwrapObservable
。