js判断一个数组对象中是否有一样的值
let userTitleLevelList=[ { "titleCode": "T002","titleLevelCode": "L001", }, { "titleCode": "T003","titleLevelCode": "L003", }, { "titleCode": "T002","titleLevelCode": "L001", }, ]; 判断userTitleLevelList数组里面是否有一样的值。比如这个里面下标0和2都是一样的"titleCode": "T002","titleLevelCode": "L001"。 const hasDuplicate = userTitleLevelList.some((item, index, array) => { return array.filter(innerItem => innerItem.titleCode === item.titleCode&&innerItem.titleLevelCode === item.titleLevelCode).length > 1; }); if(hasDuplicate){ return ElMessage.error({ message: `请不要选择相同的资质和职称!` }); }
原文地址:https://blog.csdn.net/qq_33769914/article/details/142358421
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!