<view v-for="(item, index) in deviceList" :key="item.id"
<view
@touchstart="start($event,item.id)"
@touchmove="move"
@touchend="end"
:style="[{
transform: touch.id == item.id ? 'translateX('+ touch.moveX+'px)': 0
}]"
>
</view>
</view>
export default {
data() {
return {
touch: {
id:undefined,
touchStartX: 0,
moveX: 0
},
}
},
methods: {
start(e,id) {
this.touch.id = id;
this.touch.touchStartX = e.touches[0].screenX;
},
move(e) {
if( e.touches[0].screenX > this.touch.touchStartX ){
return
}
if(this.touch.moveX < -100){
return
}
this.touch.moveX += e.touches[0].screenX - this.touch.touchStartX
this.touch.touchStartX = e.touches[0].screenX;
},
end(e) {
this.touch.moveX = 0;
this.touch.id = undefined;
},
}
}