两个数组进行权限控制---进行过滤数据

 

const mapfunc = function (routers, routermap, curlevelrouters) {
    routers.foreach(todoroute => {
      routermap.foreach(maproute => {
         if(maproute.menucode === todoroute.menucode){
           const maproutecopy = _.cloneDeep(maproute)
           const {submenulist} = todoroute
           const {children} = maproute
           if(submenulist.length>0&&children.length>0){
             maproutecopy.children = []
             curlevelrouters.push(maproutecopy)
             mapfunc(submenulist,children,maproutecopy.children)
             } else if(children.length >0&& submenulist.length === 0){
               curlevelrouters.push(maproutecopy)
             }
         }
      })
    })
   return curlevelrouters
}

 

posted @ 2020-03-25 16:20  不服憋着  阅读(263)  评论(0编辑  收藏  举报