wxml
<block class="item" wx:for="{{data}}" wx:key="index">
<view class="cell">
<movable-area class="maaa">
<movable-view class="mvvv" direction="horizontal" x="{{isOpen?'-100rpx':'0'}}" bindtouchstart="handleStart" bindtouchend="handleEnd" id="{{item._id}}">
<viewItem dataList="{{item}}"/> <!-- 自定义组件 -->
</movable-view>
</movable-area>
<button class="delBtn" id="{{item._id}}" bindtap="delSwiperItem">删 除</button>
</view>
</block>
js
let fastTouchX = 0
data: {
data: [],
isOpen: false,
id: '',
},
handleStart(evt) {
fastTouchX = evt.changedTouches[0].pageX
let id = evt.currentTarget.id
this.setData({
id
})
},
handleEnd(evt) {
let id = evt.currentTarget.id
let newTouchX = evt.changedTouches[0].pageX
let cha = newTouchX - fastTouchX
if(id != this.data.id){
return
}
if (cha < -20) {
this.setData({
isOpen: true
})
} else if (cha > 20) {
this.setData({
isOpen: false
})
} else {
this.setData({
isOpen: this.data.isOpen
})
}
},
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。