wx:if中如何改变参数的值呢?
我使用wx:for 循环判断,下面伪代码
< block wx:for = "{{pageInfo}}" wx:key = "{{item.num}}" data-code = "{{item.name}}" > < view wx:if = "{{item.num == 0}}" > < view> view > </ view > < view wx:elif = "{{item.num != 0 && item.num != 2}} " > < view > view > </ view > < view wx:else> < view > view > </ view > </ block > |
能否提取出创建线的代码,每次判断只改变颜色的值就好呢?类似下面的伪码
< block wx:for = "{{pageInfo}}" wx:key = "{{item.num}}" data-code = "{{item.name}}" > < view wx:if = "{{item.num == 0}}" > < view > //color = 紫色</ view > </ view > < view wx:elif = "{{item.num != 0 && item.num != 2}} " > < view >//color = 绿色</ view > </ view > < view wx:else> < view >//color = 蓝色</ view >
</ block > |