vue touch事件,长按1秒显示删除按钮。我是这样写的,但是实现不了,请问应该怎么修改呢?
<div class="card" v-for="(floor,index) in floors_list" @touchstart="showDeleteButton" @touchend="clearLoop">
<div class="delete-button" :class="{'delete-button-show': isDeleting}" @click="clickDelFloor(index)">x</div>
</div>
showDeleteButton() {
clearInterval(this.Loop);//再次清空定时器,防止重复注册定时器
this.Loop=setTimeout(function(){
this.isDeleting = true;
},1000);
},
clearLoop() {
clearInterval(this.Loop);
},
应该是this的指向错了
var This = this;
this.Loop = setTimeout(function(){
This.isDeleting = true;
},1000);