import default_avatar from '~/assets/img/default_avatar.png' export const useDefaultImg =(imgSrc)=>{ return imgSrc?imgSrc: default_avatar } export function throttle(func, delay) { let previous = 0; return function(...args) { const now = Date.now(); if (now - previous > delay) { func.apply(this, args); previous = now; } }; } export function debounce(func, delay) { let timer = null; return function() { const context = this; const args = arguments; // 如果定时器已经存在,清除它 if (timer) { clearTimeout(timer); } // 重新设置定时器 timer = setTimeout(() => { func.apply(context, args); }, delay); }; }