mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-07 15:45:08 +08:00
增加登陆界面
This commit is contained in:
47
yudao-vue-ui/common/js/util.js
Normal file
47
yudao-vue-ui/common/js/util.js
Normal file
@ -0,0 +1,47 @@
|
||||
let _debounceTimeout = null,
|
||||
_throttleRunning = false
|
||||
|
||||
/**
|
||||
* 防抖
|
||||
* 参考文章 https://juejin.cn/post/6844903669389885453
|
||||
*
|
||||
* @param {Function} 执行函数
|
||||
* @param {Number} delay 延时ms
|
||||
*/
|
||||
export const debounce = (fn, delay=500) => {
|
||||
clearTimeout(_debounceTimeout);
|
||||
_debounceTimeout = setTimeout(() => {
|
||||
fn();
|
||||
}, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 节流
|
||||
* 参考文章 https://juejin.cn/post/6844903669389885453
|
||||
*
|
||||
* @param {Function} 执行函数
|
||||
* @param {Number} delay 延时ms
|
||||
*/
|
||||
export const throttle = (fn, delay=500) => {
|
||||
if(_throttleRunning){
|
||||
return;
|
||||
}
|
||||
_throttleRunning = true;
|
||||
fn();
|
||||
setTimeout(() => {
|
||||
_throttleRunning = false;
|
||||
}, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* toast
|
||||
*/
|
||||
export const msg = (title = '', param={}) => {
|
||||
if(!title) return;
|
||||
uni.showToast({
|
||||
title,
|
||||
duration: param.duration || 1500,
|
||||
mask: param.mask || false,
|
||||
icon: param.icon || 'none'
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user