ko繫結雙層
<ul data-bind="foreach: data">
<li >
<div class="head">
<span class=" " data-bind="text:title"></span>
<p class="fr">
<i class=" ti-angle-down "></i>
</p>
</div>
<div class="row">
<ul class="um-list" data-bind="foreach:content">
<li class="um-list-item">
<div class="um-list-item-inner">
<div class="um-list-item-left pl15 f14" data-bind="text:value">
</div>
<div class="um-list-item-right">
<span class="fl f14" data-bind="text:value"></span>
</div>
</div>
</li>
</ul>
</div>
</li>
</ul>
data = {header:[{title:"我的工作受到了","key":"部門","value":"技術部"},{title:"我的工作受到了222","key":"部門2","value":"技術部2"},{title:"我的工作受到3333了","key":"部門3","value":"技術部3"}],
content:[
{
title:"我的工作1",
content:[{"key":"部門1","value":"技術部1"},{"key":"部門2","value":"技術部2"},{"key":"部門3","value":"技術部3"}]
}
,{
title:"我的工作2",
content:[{"key":"部門4","value":"技術部4"},{"key":"部門5","value":"技術部6"},{"key":"部門6","value":"技術部6"}]
},{
title:"我的工作影響",
content:[{"key":"部門9","value":"技術部9"},{"key":"部門8","value":"技術部8"},{"key":"部門7","value":"技術部7"}]
}
],
footer:{"作業":"多撒多撒打大三打打薩迪克了幾口經理看見嗯我我機票錢餓哦切坡熊奇葩"},
}
viewModel ={
data:ko.observableArray(data.content),//[]
data1:ko.observableArray(data.header),//[]
};
ko.applyBindings(viewModel);