vue数组循环遍历中途跳出整个循环,使用some进行循环,return true时,跳出整个循环
judgePoint(arr) {
if (this.haveError) {
this.haveError = false
}
arr.some((item, index) => {
if (item.x.match(/^(\-|\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,6})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,6}|180)$/)) {
if (!item.y.match(/^(\-|\+)?([0-8]?\d{1}\.\d{0,6}|90\.0{0,6}|[0-8]?\d{1}|90)$/)) {
this.$message({
type: 'warning',
message: '点' + (index + 1) + '纬度为-90~90,小数限6位'
})
this.haveError = true
return true
}
} else {
this.$message({
type: 'warning',
message: '点' + (index + 1) + '经度为-180~180,小数限6位!'
})
this.haveError = true
return true
}
});
},