会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
lcjspace
博客园
首页
新随笔
联系
订阅
管理
2022年8月1日
React函数组件模拟生命周期的方法
摘要: useEffect 没有依赖项,那它会在每次render之后执行 模拟componentDidMount-useEffect依赖[] 模拟componentDidUpdate-useEffect无依赖,或者依赖[a, b] 模拟componentWillUnMount-useEffect中返回一个函
阅读全文
posted @ 2022-08-01 14:24 不知码
阅读(70)
评论(0)
推荐(0)
2022年7月5日
防抖节流实现
摘要: 1.防抖 function debounce(fun, time) { let timers; return function(){ clearTimeout(timers); let arg = arguments; timers = setTimeout( () => { fun.apply(t
阅读全文
posted @ 2022-07-05 19:23 不知码
阅读(19)
评论(0)
推荐(0)
一维数组转二维数组
摘要: function arrTrans(num, arr) { // 一维数组转换为二维数组 const iconsArr = []; // 声明数组 arr.forEach((item, index) => { const page = Math.floor(index / num); // 计算该元
阅读全文
posted @ 2022-07-05 19:06 不知码
阅读(59)
评论(0)
推荐(0)
reduce使用例子
摘要: 1. 对象数组去重 let arr = [ {name: 'mom', id:1}, {name: 'timo', id:2}, {name: 'mom', id:1}, {name: 'timo', id:2}, ] let obj={}; const newarry = arr.reduce(
阅读全文
posted @ 2022-07-05 18:19 不知码
阅读(43)
评论(0)
推荐(0)
公告