//在preventReClick.js中封装防抖方法
export const Debounce = (fn, wait) => {
let delay = wait|| 500
let timer
return function () {
let args = arguments;
if (timer) {
clearTimeout(timer)
}
let callNow = !timer
timer = setTimeout(() => {
timer = null
}, delay)
if (callNow) fn.apply(this, args)
}
}
//页面内
<view class="btn" @click="submit()">下一步</view>
//页面中引用
import {Debounce} from '@/common/preventReClick.js'
methods:{
submit: Debounce(function(e) {
//在点击事件内写你点击按钮的功能
},1000),
}