// 节流
export function _throttle(fn, wait =500){
let last, now
returnfunction(){
now =Date.now()if(last && now - last < wait){
last = now
}else{
last = now
fn.call(this,...arguments)}}}// 防抖
export function _debounce(fn, wait =500){
let timer
returnfunction(){
let context =this
let args = arguments
if(timer)clearTimeout(timer)
timer =setTimeout(()=>{
fn.apply(context, args)}, wait)}}