vue如何过滤出一个数组中不包含另一个数组的数据

data里面定义测试数组

arr1:[1,3,5,7,11,0],
      arr2:[1,11],
      arrres:[]

然后过滤一下

for(let one of this.arr1){
      if (this.arr2.indexOf(one) == -1) {
                //解释:如果新数组里没有就放进去,有就放不进了
                this.arrres.push(one);
              }
    }
    console.log("ceshi数组相减",this.arrres)

 

posted @ 2022-11-05 19:27  sgj191024  阅读(1144)  评论(0)    收藏  举报