使用el-cascader,动态添加disabled
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210512154930238.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxODM4NDM1,size_16,color_FFFFFF,t_70#pic_center)
export function addDisabled(dropdownList) {
const list = []
try {
dropdownList.forEach((e, index) => {
let e_new = {
nodeId: e.nodeId,
label: e.label,
isLeaf: e.isLeaf
}
if (!e.children && e.isLeaf === 0) {
e_new = { ...e_new, disabled: true }
}
if (e.children) {
const children = addDisabled(e.children)
e_new = { ...e_new, children: children }
}
list.push(e_new)
})
} catch (error) {
console.log(error)
return []
}
return list
}
import { addDisabled } from '@/utils/addDisabled'
this.inputNodeList = addDisabled(res.list)