huyueshan

导航

2019年12月12日 #

扁平数据根据`parentId`生成树结构

摘要: 根据每项的parentId,生成具体树形结构的对象。 const nest = (items, id = null, link = 'parent_id') => items .filter(item => item[link] == id) .map(item => ({ ...item, chi 阅读全文

posted @ 2019-12-12 23:05 huyueshan 阅读(2389) 评论(1) 推荐(0) 编辑

页面滚动到指定元素区域

摘要: 该代码段可将指定元素平滑滚动到浏览器窗口的可见区域。 const smoothScroll = element => document.querySelector(element).scrollIntoView({ behavior: 'smooth' }); smoothScroll('#fooB 阅读全文

posted @ 2019-12-12 22:50 huyueshan 阅读(765) 评论(0) 推荐(0) 编辑