触发touchstart后,给当页变量赋值,会刷新静态页。去掉this.setData({...........})之后就触发bindtouchend了。
bindtouchend 失效<view class="zore" bindtouchstart="touchStartImg" bindtouchend="touchCansceImg" bindtouchcancel="touchcancel" bindlongpress='longpress'> <view wx:if="{{show}}" class="gif"> <view>1</view> <image style="width: 200px; height: 200px; background-color: #eeeeee;" mode="scaleToFill" src="cloud://dev-0gccbidx1b0024c7.6465-dev-0gccbidx1b0024c7-1309288604/1.jpg"></image> </view> <view wx:else="{{!show}}" class="static"> <view>2</view> <image style="width: 200px; height: 200px; background-color: #eeeeee;" mode="scaleToFill" src="cloud://dev-0gccbidx1b0024c7.6465-dev-0gccbidx1b0024c7-1309288604/iqiyi_1647414830485.gif"></image> </view> </view> // pages/calculate/calculate.js Page({ /** * 页面的初始数据 */ data: { show:true }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, /** * */ touchStartImg(){ console.log("开始触碰") this.setData({ show:false }) }, touchCansceImg(){ console.log("触碰结束"); this.setData({ show:true }) }, longpress(){ console.log("longpress"); this.setData({ show:true }) }, touchcancel(){ console.log("cancel"); this.setData({ show:true }) }, longpress(){ console.log("longpress"); this.setData({ show:true }) } }) [图片] 长按后bindtouchend触发成功一次。下一次在长按bindtouchend就失效了
2022-12-04