uniapp vue 函数方法中的遍历数组方式
for 循环遍历
for (let i = 0; i < this.list.length; i++) {
if (scrollTop > this.list[i].top && scrollTop < this.list[i].bottom) {
this.verticalNavTop = (this.list[i].id - 1) * 50
this.tabCur = this.list[i].id
console.log(scrollTop)
return false
}
}
forEach 循环遍历
that.cates.forEach(item=>{
if(item.length>0){
item.child.forEach(child=>{
if(item.id==pid && id==child.id){
that.catename=child.name
that.orderindex=child.orderindex
that.cateid = chilid.id
}
})
}
})