uniapp event multiple click processing

  1. Create a new js (utils.js) in the common file directory
function onClickOne(fun,data){
    
    
	let _this = this;
	if(clickFalg){
    
    
		_this.clickFalg = false
		if(data !== '' && data){
    
    
			fun(data)
		}else{
    
    
			fun()
		}
		setTimeout(() => {
    
    
			that.noClick = true;
		}, 2000)
	}else{
    
    
		console.log('多次点击')
	}
}
export default{
    
    
	onClickOne
}

2. The second step main.js import

import utils from  '@/common/utils.js'
Vue.prototype.$oneClick = utils.onClickOne;

3. The third step is to use it on the page we need to use

	data()	{
    
    
		return	{
    
    
			noClick:true
		}
	}
<view @click="getData('我是参数')"></view>//原来的写法
<view @click="$oneClick(getData,'我是参数')"></view>//新的写法

Guess you like

Origin blog.csdn.net/weixin_41688609/article/details/121245078