html52.com
我爱小程序-开发者交流社区

小程序for循环后,点击事件,单击一个按钮后,其他按钮一起变,如何给图片加上id?求助!

    <view class="anniu" wx:if="{{isplay==false}}" bindtap='play'  data-ypname='{{item._id}}' id="{{index}}"  >
      <image src='../../images/play.png' style="width:50px;height:50px;"></image>
    </view>
    <view class="anniu"  wx:if="{{isplay==true}}" bindtap='stop'>
      <image src='../../images/pause.png' style="width:50px;height:50px;"></image>
    </view>


    play: function (ypname) {
      var dataset = ypname.currentTarget.dataset;
      var ypname = dataset.ypname;
      db.collection('PyFile').where({
        _id: ypname
      })
      .get({
        success: function(res) {
          myaudio.src = res.data[0].file
        }
      })
      //播放音频
      myaudio.play();
      console.log(myaudio.duration);
     this.setData({ isplay: true });
    
    },
    // 停止
    stop: function () {
      myaudio.pause();
      this.setData({ isplay: false });
    }


 });
    }
 });
    }

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付