如何实现轮播来控制图片按钮的显示隐藏?

发布于 7 年前作者 litao1323 次浏览最后编辑 7 年前来自 issues

<view class="box"><swiper indicator-active-color="#ff832a" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" current="0" bindchange="swiperChange" style="width: 100%; height: 120rpx; display: block; box-sizing: border-box; left: NaNrpx; top: NaNrpx">

      <block wx:for="{{imgUrls}}" wx:key="lunbo">

        <swiper-item >

          <image style="width:100%; height: 120px; display: inline-block; box-sizing: border-box; left: NaNrpx; top: NaNrpx"  src="{{item}}" />

        </swiper-item>

      </block>

    </swiper></view>

<image wx:if="{{flag}}" class="xindex1" bindtap='enterShow' src="/resource/Rcicon.png"></image>

js:

  swiperChange: function (e) { 

    e.detail.current == 0 ? this.flag = true : this.flag = false

    console.log(this.flag)

  },

改变轮播图片,能输出flag的值。但是w-if判断就是不能隐藏图片

1 回复
yan75
yan751 楼5 年前
swiperChange: function (e) { 
  this.setData({
    flag: e.detail.current == 0 ? true : false
  })

  console.log(this.data.flag)
},