Is vue hungry? is it invalid to add tree table nodes?

it"s not easy to make better use of the components, resulting in a lot of problems!

<!--  -->
              <el-button
                icon="el-icon-plus"
                circle
                :size="iconSize"
                type="success"
                @click="NodeAdd(node, data)"
              ></el-button>

this is the html added to the node

NodeAdd(n, d) {
      //
      console.log(n, d);
      //
      if (n.level >= 3) {
        this.$message.error("");
        return false;
      }
      //
      d.list.push({
        id: PPthis.maxexpandId,
        name: "",
        pid: d.id,
        list: []
      });
      //
      if (!n.expanded) {
        n.expanded = true;
      }
    }

this is a way to add nodes. Others are fine for top-level nodes, but an error is reported when adding to secondary nodes

clipboard.png
I don"t know what went wrong. I"m tired!

May.06,2022

look at the d.list you printed out is an object, not an array, and the object does not have a push method, so an error has been reported!


NodeAdd(n, d) {
      //
      console.log(n, d);
      //
      if (n.level > 3) {
        this.$message.error("");
      }else{
          //listd.listundefined,push
          if (!d.list) {
            this.$set(d, 'list', []);
          }
          //
          d.list.push({
            id: PPthis.maxexpandId,
            name: "",
            pid: d.id,
            list: []
          });
          //
          if (!n.expanded) {
            n.expanded = true;
          }
      }
    }
Menu