鍍金池/ 問答/HTML/ vue touch事件,長按1秒顯示刪除按鈕。

vue touch事件,長按1秒顯示刪除按鈕。

vue touch事件,長按1秒顯示刪除按鈕。我是這樣寫的,但是實現(xiàn)不了,請問應(yīng)該怎么修改呢?

<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);//再次清空定時器,防止重復(fù)注冊定時器
    this.Loop=setTimeout(function(){
        this.isDeleting = true;
    },1000);
},
clearLoop() {
    clearInterval(this.Loop);
},
回答
編輯回答
朕略傻

可以使用箭頭函數(shù)
setTimeout(() => {}, timeout);

2017年4月6日 20:19
編輯回答
我不懂

應(yīng)該是this的指向錯了

var This = this;
this.Loop = setTimeout(function(){
This.isDeleting = true;
},1000);

2017年1月18日 08:45
編輯回答
厭惡我
 this.Loop=setTimeout(function(){
        this.isDeleting = true;
    }.bind(this),1000);
2018年7月25日 10:45