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

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
}

猜你喜欢

转载自www.cnblogs.com/cs122/p/12566937.html