some 对于遍历数组,其值返回的是一个布尔值,它会对每一个元素,执行一次指定函数,直到返回true
代码示例如下:我这个是一个数组对象:只要每一项有num 为0,将无法满足领取条件
flag : 是一个是一个返回的布尔值
that.data.words: 是需要遍历的数组
item:每一项的数据
item.num==0 条件
//领取赠品
get:function(){
var that=this
//flag 是一个布尔值
let flag = that.data.words.some(item=>item.num == 0)
if(flag==false){
console.log("111111")
}else{
console.log("222222")
}
},