【问题标题】:Titanium ListView template conditional renderingTitanium ListView 模板条件渲染
【发布时间】:2019-07-03 11:41:44
【问题描述】:

有谁知道如何根据传入的 bindId 有条件地在列表视图模板中呈现视图?

我有一个模板,只有在传入的标签不为空时才显示视图。

<View class="productBannerLabelWrapper productBanner1">
   <Label class="productBannerLabel" bindId="productBanner1" />
</View>

标签周围有一个视图,因为标签需要一个比标签本身更大的有领背景。

感谢您的帮助

【问题讨论】:

    标签: titanium appcelerator-titanium listviewitem titanium-alloy


    【解决方案1】:

    当您填写项目数组时,您可以像这样设置visible 属性:

    var prop = {
      productBanner1: {
         text: "Text",
         visible: (checkValue)?1:0
      }
    }
    items.push(prop);
    $.list_section.items = items;
    

    含合金:

    为可见参数添加数据绑定,例如productBanner:visible="{isVisible}",并在分配模块之前使用dataTransform 更改模块:

    function transformFnc(model) {
        return {
            otherStuff: model.attributes.otherStuff
            isVisible: (checkValue)?1:0
        }
    }
    

    【讨论】:

    • 我正在使用集合和合金数据绑定来填充列表。你知道这对合金有什么作用吗?
    • 当然,在上面的帖子中添加了一个示例。您可以使用dataTransform 函数
    猜你喜欢
    • 2016-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-02
    • 2018-04-21
    • 1970-01-01
    • 2010-11-30
    相关资源
    最近更新 更多