1.比如第一个下拉框选中的值,其他的下拉框就必须禁用该值,并且第一个下拉框的该值不能被禁用
var arr = [{code:'1',name:'fff1'},{code:'2',name:'fff2'},{code:'3',name:'fff3'},{code:'4',name:'fff4'}];
var arr1 = ['1','2','3']
var arr2 = ['1','2','3','5']
// 遍历arr1三个值,是否在arr中存在重复,如果有就添加属性disabled:true,都没有才添加属性disabled:false
for(let i = 0,len = arr.length; i < len ; i ++){
let item1 = arr[i];
for(let j = 0, len = arr1.length; j < len ; j ++){
let item2 = arr1[j];
if(item1.code == item2){
arr[i].disabled = true;
break
}else{
arr[i].disabled = false;
}
}
}
其实真实情况可能更加复杂,还好都已经解决了