在网上提供的查询方法有很多;
但是实例的时候都太过于简单
和现实业务反差太大;
现实践业务中数据相对复杂;
大多都是数组对象中处理查询;
以下是本人总结相对好用的:
核心讲解: 在es8的新方法中有一个find()方法提供在数组或数据对象中查询一个元素;并
返回该元素
举例如下:
let stateFlag = that.communityReturnList.find( cItem => item.communityCode == cItem.communityCode);
that.showCommunity_shell = false;
if(stateFlag){
that.$toast('该小区已存在,请勿重复添加');
return;
}else{
that.communityReturnList.push(item);
}