/** * 解决el-cascader控件 最后一级暂无数据仍然显示。 * @param data * @returns {Array} */ export function getTreeData(data){ for(let i=0;i<data.length;i++){ if(data[i].child.length<1){ // child若为空数组,则将child设为undefined data[i].child=undefined; }else { // child若不为空数组,则继续 递归调用 本方法 getTreeData(data[i].child); } } return data; }