// 处理多次点击 function noMultipleClicks(methods) { //复制this对象指向当时的this,防止找不到原来的对象 let that = this; if (that.noClick) { that.noClick = false; //点击方法 methods(); setTimeout(function() { that.noClick = true; }, 2000) } else { uni.$showMsg('正在加载中', 500) } } //获取胶囊位置信息 function getCapsuleSite() { let res = uni.getMenuButtonBoundingClientRect() this.capsuleBottom = res.bottom + 5 this.capsuleMiddle = res.left this.capsuleWidth = res.width } //导出并在Main.js中全局注册 export default { noMultipleClicks, //禁止多次点击 getCapsuleSite, //获取胶囊位置信息 }