问题描述
我有以下对象:
parent = {
prop1: "asd",prop2: "zxc",arr: [
{
title: "qwe",attr: {attr1: "987",attr2: "dfg"}
},{
title: "poi",attr: {attr1: "345",attr2: "jkl"}
}
]
}
我要将其绑定到以下列表:
<List id="list" items="{parent>/arr}" headerText="Example">
<items>
<ObjectListItem title="{parent>arr/title}" type="Active" press="onListItemPress">
<attributes>
<ObjectAttribute text="{parent>arr/attr/attr2}" />
</attributes>
</ObjectListItem>
</items>
</List>
我无法使其正常工作。
在此列表中显示 title 和 attr2 属性的正确方法是什么?
解决方法
尝试下面的语法视图绑定:
<List id="list" items="{parent>/arr}" headerText="Example">
<items>
<ObjectListItem title="{parent>title}" type="Active" press="onListItemPress">
<attributes>
<ObjectAttribute text="{parent>attr/attr2}" />
</attributes>
</ObjectListItem>
</items>
</List>