Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

1. 使用变量

使用变量的格式:{{字段名}}  ,例如:

{{门店名称}}  
{{city}}  

 

访问Map对象格式: 变量名["字段名"] , 例如遍历dataRow时:

item["销售额"]

2. 变量的计算

可以直接使用计算符号,例如: 

//直接计算字段变量
{{ 销售额/10000 }} 万元
{{ ( (销售额-去年销售额) / 去年销售额 ) * 100 }}

//遍历dataRow时,计算字段列,必须对字段使用括号
{{ ( ( (item["销售额"])-(item["去年销售额"])) / (item["去年销售额"]) ) * 100 }}

 

3. 控制语句

if ... else
{% if (销售额 > 300) %}
<div>销售额大于300了!</div>
{% elseif (销售额 > 100) %}
<div>销售额在100与300之间!</div> 
{% else %}
<div>销售额不足100!</div> 
{% endif %}
for循环
{% for item in dataRow %}
序号: {{loop.index}}, 销售额: {{item["销售额"]}}
{% endfor %}

 

4. 内置函数

 

函数描述使用示例
dataRow通过alarm.add()方法添加的数据行请参考for循环代码块
abs绝对值{{abs(销售额)}}
number_format数字格式化,有4个参数:
参数1:变量
参数2:小数位
参数3:小数点
参数4:千分位 

1. 两位小数
{{ number_format(利润率, 2) }}
2. 千分位整数
{{ number_format(销售额, 0,'',',') }}

   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

 

 

 

 

  • No labels