shoppingId: [“45CD4EBA20CC426598D29F10D3E70992”],
shoppingId是个数组
<icon type=‘success’ size=‘20’ style=‘margin-right:10px;’ wx:if=’{{shoppingId.indexOf(item.id)==-1}}’ bindtap=‘rightitemclick’ data-position=’{{index}}’></icon>
这样出来的结果一直是false,求大神指导
把icon循环出来只有item == itemName.id的显示 其余的不显示 都不等于都不显示 有错?(这个性能不咋滴)
orders把这个数据在js里循环一遍 加个flag专门判断icon显示隐藏 没必要非在页面判断
<view wx:for="{{orders}}" class=‘order-item-right’ wx:for-item=“itemName”>
外层wx:for
<icon type=‘success’ size=‘20’ style=‘margin-right:10px;’ wx:for="{{shoppingId}}"
wx:if=’{{item == itemName.id}}’
bindtap=‘rightitemclick’ data-position=’{{index}}’></icon>
试试这个
刚刚测试的结果,wx:if=’{{shoppingId.indexOf(item.id)==undefined}}'是true,shoppingId.split().indexOf(item.id)==undefined也一样都是true
确实没有必要在页面里面判断,应该加个falg在js中去判断,谢谢
<wxs module=“util”>
var inOf = function(list, val) {
return list.split().indexOf(val)
}
module.exports.inOf = inOf;
</wxs>
wx:if=’{{util.inOf(shoppingId,item.id)==-1}}’
<scroll-view scroll-y class=“orders-list-order” style=‘height:{{right_scrollheight}}px’ >
<view wx:for="{{orders}}" class=‘order-item-right’>
<image src=’{{item.P_ICON}}’ class=‘order-item-imag’></image>
<view class=‘order-item-text-right’ >
<view class=‘order-item-right-name’>{{item.P_NAME}}</view>
<view style=‘display:flex;margin-top: 30px;width:100%;justify-content:space-between’>
<view class=‘order-item-right-price’>¥{{item.P_PRICE}}</view>
<icon type=‘success’ size=‘20’ style=‘margin-right:10px;’ wx:if=’{{shoppingId.indexOf(item.id)==-1}}’ bindtap=‘rightitemclick’ data-position=’{{index}}’></icon>
<view style=‘margin-right:10px;display:flex’ wx:else>
<icon type=‘success’ size=‘20’ data-position=’{{index}}’></icon>
<view style=‘padding-left:5px;padding-right:5px;font-size:small’>1</view>
<icon type=‘success’ size=‘20’ bindtap=‘rightitemclick’ data-position=’{{index}}’></icon>
</view>
</view>
</view>
</view>
</scroll-view>