做一个项目遇到个难题,就是一个循环数据列表里面有一个添加购物车的按钮,点击此按钮的时候要隐藏这个按钮出现+ - 号。这一部没有问题,但出现了一个新的问题,就是在点击其他购物车按钮的时候,已经隐藏的按钮显示出来了!请问这个问题有人遇到过吗?
<view class="hot-box">
<view class="hot-title-img"><image src="../images/sc-03.png"></image></view>
<view class="hot-list-box" wx:key="id" wx:for="{{ProductList}}">
<view class="hot-list-white">
<view class="hot-list-img">
<image src="{{item.ImgFile}}" style="z-index: 1;position: absolute;top: 0;left: 0;"></image>
<image class="sale-img" src="../images/sc-29.png"> </image>
</view>
<view class="hot-list-title">{{item.ShopName}}</view>
<view class="hot-list-content">
<view class="hot-list-content-left">预售时间:07月30日</view>
<view class="hot-list-content-right">今日已售2000箱/限量3000箱</view>
<view class="hot-list-content-left">提货时间:07月30日</view>
</view>
<view class="hot-price">¥{{item.ActivityPrice}}<text class="del">{{item.Price}}</text></view>
<view class="hot-button-box">
<button open-type='share' class="ShareButton" data-proid='{{item.ShopNo}}' data-imgurl='{{item.ImgFile}}'>分享</button>
<button bindtap='ShopCar' id="proid-{{item.ShopNo}}" data-proid="{{item.ShopNo}}" wx:if="{{Jshide!=item.ShopNo}}" class="btnAddCar" >加入购物车</button>
<view class="js {{Jshide==item.ShopNo?'Show':'hidden'}}" >{{item.ShopNo}}</view>
</view>
</view>
</view>
</view>
data: {
Jshide:0,
UserOpenid:"",
ProductList:[],
},
ShopCar:function(options){
var that=this;
var toggleBtnVal = that.data.Jshide;
var TargetId=options.target.dataset.proid;
if (toggleBtnVal == TargetId) {
that.setData({
Jshide: 0
})
}else{
that.setData({
Jshide: options.target.dataset.proid
})
}
}