一般业务场景钟会需要用到 遍历,但需要打断,请看以下例子
一般业务场景钟会需要用到 遍历
// 判断是否跨年
judgeCoverYear (arr) {
this.isCoverYear = false
arr.forEach((item,index) => {
if (this.isCoverYear) {
return true
} else {
this.isCoverYear = !(arr[0].date.substr(0, 4) === arr[index].date.substr(0, 4))
}
})
return this.isCoverYear
},
// 在别的地方来调用进行判断
this.judgeCoverYear()