合肥做网站的公,教人做甜品的网站,男科医院网站建设公司,python nginx做网站数组中有很多对象 , 需根据当前页面的值current 和 数组中的key对比 拿到返回值 数据结构如下 之前写法
const clickedItem routeList.find(item item.key current) // current是当前页 用reduce遍历数组返回最后一个值 const clickedItem routeList.reduce((lastIte…数组中有很多对象 , 需根据当前页面的值current 和 数组中的key对比 拿到返回值 数据结构如下 之前写法
const clickedItem routeList.find(item item.key current) // current是当前页
用reduce遍历数组返回最后一个值 const clickedItem routeList.reduce((lastItem, currentItem) currentItem.key current ? currentItem : lastItem,null)