给查询按钮增加防抖功能
utils/common.js中:
export function noMultipleClicks(methods, info) {
let _this = this
if (_this.noClick) {
_this.noClick = false
if (info && info !== '') {
methods(info)
} else {
methods()
}
setTimeout(() => {
_this.noClick = true
}, 2000)
} else {
uni.showToast({
icon: 'none',
title: '点击太频繁,请稍后再试.'
})
}
}
main.js中:
import {
noMultipleClicks } from '@/utils/common.js'
Vue.prototype.$noMultipleClicks = noMultipleClicks
各个文件中:
<button @click="$noMultipleClicks(btnSearch)" type="primary" size="mini">查询</button>
data () {
return {
noClick: true,
}
},
methods: {
btnSearch() {
......
}
}
路由传参
uni.navigateTo({
url: `@/pages/me/name=${
'James'