element cascader 最后一级为空问题

531 阅读1分钟

将最后一级children 递归 置为 undefined

// 获取数据
commonApi.officeTree().then(resp => {
    if (resp.status === 'SUCCEED') {
        let data = resp.result;
        this.getTypeList(data);
        this.conpanyOptions = data;
    }
})

// 递归遍历
getTypeList(commodityType) {
    commodityType.forEach(items => {
        if (items.children.length > 0) {
            this.getTypeList(items.children);
        } else {
            items.children = undefined;
        }
    });
},