我正在使用内置的ListView并进行以下设置 .
<ListView items="{{ myItems }}" itemLoading="onItemLoading" itemTemplateSelector="onTemplateSelector">
<ListView.itemTemplates>
<template key="even">
<Label text="{{ age }}" style.backgroundColor="white" />
</template>
<template key="odd">
<Label text="{{ age }}" style.backgroundColor="gray" />
</template>
</ListView.itemTemplates>
在onLoadingEvent中 - 每个项目即将被加载,我看看args.view并且它总是未定义的 . 我原以为它是完整的模板视图结构 - 取决于onTemplateSelector返回的内容 .
看一些更多的文档,似乎如果它未定义,那么你必须在代码中创建整个结构 .
我错过了什么?如果不是,那么允许模板项定义的目的是什么(例如我的示例代码中的Label) .
1 回答
如果你这样做
<ListView.itemTemplates> <Label text="{{ age }}" style.backgroundColor="gray" /> </ListView.itemTemplates>
那会很好 . 我不确定你的
<template>
元素是什么 .