10 2023 档案
摘要:自定义事件总线 自定义事件总线属于一种观察者模式,其中包括三个角色: 口发布者(Publisher):发出事件(Event); 口订阅者(Subscriber):订阅事件(Event),并且会进行响应(Handler); 口事件总线(EventBus):无论是发布者还是订阅者都是通过事件总线作为中台
阅读全文
摘要:深拷贝基本实现 1 深拷贝基本实现 2 function isObject(value){ 3 const valueType=typeof value 4 return (value!==null)&&(valueType 'object'||valueType 'function') 5 } 6
阅读全文
摘要:防抖函数基本实现 1 function debounce(fn,delay){ 2 let timer=null 3 return function(...args){ 4 if(timer)clearTimeout(timer) 5 timer=setTimeout(() => { 6 fn.ap
阅读全文