Xtemplate if sencha touch 中的条件 [英] Xtemplate if conditions in sencha touch

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

问题描述

我有以下 Xtemplate 代码:

('Ext.XTemplate','<div class="moreArrow"></div>','<div class="img"><img src="http://localhost/WL2/assets/rest/{image}"/></div>','<div class="meta">','<h3>{商品名称}</h3>','

','<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 class="want{[values.wantToSee ? "selected" : ""]}">想要去那里</button>','{%}%}','</div>','</div>')

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

解决方案

它可能不起作用,因为你没有将它与任何东西进行比较.

顺便说一句,这里有几个例子来理解如何使用if条件:

使用比较运算符:

使用AND"运算符

使用 XTemplates 变量:

'{% if (xindex % 2 === 1) { %}' +'<div>奇数行</div>'+'{%} %}'

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>'
)

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, here are few examples to understand how to use if condition:

Using comparison operators:

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

Using 'AND' operator

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

Using XTemplates variables:

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

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

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