随笔分类 -  工具函数

摘要:const transformTimestamp = (timestamp) => { let a = new Date(timestamp).getTime(); const date = new Date(a); const Y = date.getFullYear() + "-"; const 阅读全文
posted @ 2022-10-28 10:26 w1ndz 阅读(43) 评论(0) 推荐(0) 编辑
摘要:####节流:在设定的时间内,只能执行一次,重复执行不生效 functon throttle(fn,wait=50){ //初始化一个变量用于存上次执行的时间戳 let item=0; return function(...rest){ //生成最新的时间戳 let newItem=new Date 阅读全文
posted @ 2022-03-29 17:18 w1ndz 阅读(88) 评论(0) 推荐(0) 编辑
摘要:####防抖:一个函数在规定的时间内只能执行一次,重复执行会重置等待的时间 function debounced(fn, wait = 50) { let item; return function (...rest) { if (item) clearTimeout(item); item = s 阅读全文
posted @ 2022-03-29 17:09 w1ndz 阅读(68) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示