uni-app長按刪除

(1)在你要長按的盒子《標籤》上添加如下代碼

@touchstart.prevent="touchstart(index)"   @touchend.prevent="touchend"

(2)編寫touchstart函數

touchstart(index) {
				let that = this;
				clearInterval(this.Loop); //再次清空定時器,防止重複註冊定時器
				console.log(index)
				this.Loop = setTimeout(function() {
					uni.showModal({
						title: '刪除',
						content: '請問要刪除本條消息嗎?',
						success: function(res) {
							if (res.confirm) {
								console.log(this.noticeList)
								//alert(this.noticeList[index].id)
								deleteNotify(that.noticeList[index].id, '0').then(res => {
									if (res.data.code == 1) {
										uni.showToast({
											title: '刪除成功',
											duration: 2000
										})
										that.getnotify();
									}
								})
							} else if (res.cancel) {
								console.log('用戶點擊取消');
							}
						}
					});
				}.bind(this), 1000);
			},

(3)編寫touchend函數

touchend() {
				console.log('結束')
				clearInterval(this.Loop);
			}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章