vue 中 过滤filter 和 foreach的使用

const list  =  listArr.filter ( item => item.check)  //过滤 listArr中check属性不为空的数据

循环 获取所有数据的Id以及子节点的数据Id

let list = []

const rowmapId  = (item) => {

     if (item.length > 0){

         item.foreach(i => {

           list.push(i.id)

           if(i.childen.length > 0){

              rowmapId(i.childen)

             }

         })

     }

}

猜你喜欢

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