1.级联选择器的选不中的BUG处理。
用element-ui的级联选择器时后台数据渲染上去但是选不中,最后发现是后台返回的数据有问题,children没有他也给我返回来一个空数组,所以级联选择器以为你后面还有children,所以总是选不中,这时候就需要你写一个函数还去除后台返回数据的空数组。我是这样写的,附代码:
const deleteEmptyChild = (arr) => {let res = arr;if (arr instanceof Object) {if (Array.isArray(arr)) {res = arr.map((obj) => {return deleteEmptyChild(obj);});} else if (arr.children) {if (!Array.isArray(arr.children)) {delete arr.children;} else if (arr.children.length === 0) {delete arr.children;} else {arr.children = deleteEmptyChild(arr.children);}res = arr;}return res;}};
把后台返回的数据传进去处理一下就行










