快速点击多次触发问题

点击签到的时候,有的用户会快速点击签到按钮,这会导致接口不断调用,需要节流限制一下

<view class="btom">
	<view class="btn" @tap="qiandao">
		签到
	</view>
</view>
export default {
	data() {
		return {
		requestDone: false,
               }
	}
}, 
methods:{
	async qiandao() {
		if (this.requestDone) {
			return;
		}
		try {
			this.requestDone = true;
			await this.signin(); //调用签到的接口
		} finally {
			setTimeout(() => {
				this.requestDone = false;
			}, 1000)
		}
	},
}

  

posted @ 2022-09-30 10:05  飞飞要努力  阅读(36)  评论(0)    收藏  举报