element-ui级联选择器 Cascader 空白

vue yekong 2035℃

最底层 的子项中 的 children 为空数组,这样就会造成,空级联 的bug存在。
CleanShot 2021-01-31 at 11.31.18@2x

getTreeData(data) {
      // 循环遍历json数据
      for (var i = 0; i < data.length; i++) {

        if (data[i].children.length < 1) {
          // children若为空数组,则将children设为undefined
          data[i].children = undefined;
        } else {
          // children若不为空数组,则继续 递归调用 本方法
          this.getTreeData(data[i].children);
        }
      }
      return data;
    },
    async category() {
      var restaurants = await category({});
      if (restaurants.code == 200) {
        this.categorylist = this.getTreeData(restaurants.result)
      } else {
        this.$message.error(restaurants.message);
      }
    },
喜欢 (10)