【问题标题】:Nativescript ListView onItemLoading eventNativescript ListView onItemLoading 事件
【发布时间】:2017-03-23 10:31:01
【问题描述】:

我正在使用内置的 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 返回的内容。

查看更多文档,似乎如果它未定义,那么您必须在代码中创建整个结构。

我错过了什么吗?如果不是,那么允许模板项定义的目的是什么(例如我的示例代码中的标签)。

【问题讨论】:

  • 一种解决方法可能是 - 我可以将字符串中的 xml 定义传递给函数并让它在 xml 中创建视图。这在 {N} 中没有 Angular。

标签: nativescript


【解决方案1】:

如果你这样做

<ListView.itemTemplates> <Label text="{{ age }}" style.backgroundColor="gray" /> </ListView.itemTemplates>

这样就可以了。我不确定你的 &lt;template&gt; 元素是什么。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    • 2018-09-20
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 2019-10-18
    相关资源
    最近更新 更多