Xtemplate如果条件触摸 [英] Xtemplate if conditions in sencha touch

查看:99
本文介绍了Xtemplate如果条件触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Xtemplate代码:

I have the following Xtemplate code:

('Ext.XTemplate',
    '<div class="moreArrow"></div>',
    '<div class="img"><img src="http://localhost/WL2/assets/rest/{image}"/></div>',                       
    '<div class="meta">',
    '<h3>{merchName}</h3>',
    '<div class="actions">',
        '<button class="seen{[values.seen ? " selected" : ""]}">{action}</button>',
        '{% if (values.seen) { %}',
            '<button class="thumb up{[values.like ? " selected" : ""]}"><b></b></button>',
            '<button class="thumb down{[values.dislike ? "selected" : ""]}"><b></b>  </button>',
        '{% } else { %}',
            '<button class="want{[values.wantToSee ? "selected" : ""]}">Want to Go There</button>',
        '{% } %}',
        '</div>',
    '</div>'
)

我的问题是,部分 {%if(values.seen){%} 中的if条件不起作用,就是当按钮被点击,它应该显示两个不喜欢的按钮。我的代码是什么问题导致这个问题?

My problem is that the if condition in the part {% if (values.seen) { %} is not working, that is when the button is clicked, it should show two buttons of dislike and like. What is wrong with my code that is causing this issue?

推荐答案

这可能不工作,因为你没有与任何东西进行比较

It might not be working because you are not comparing it with anything.

BTW,以下是几个例子,了解如何使用 if 条件:

BTW, here are few examples to understand how to use if condition:

使用比较运算符:

<tpl if="totalDiscount &gt; 0">

使用AND运算符

<tpl if="active == true && available == true">

使用XTemplates变量:

Using XTemplates variables:

'{% if (xindex % 2 === 1) { %}' +
    '<div>Odd Row</div>' +
'{% } %}'

这篇关于Xtemplate如果条件触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆