Element-ui Tree control, how to get the ID? of the parent node

how to get the ID? of the parent node when clicking on the node The event of the parent node is not specifically obtained in the official website api. The current click data can be obtained by binding the getNode method, but storing the ID of the parent node is mostly said on the Internet to operate by changing the source code, but the project online source code submission is another problem, is there a better solution?

<el-tree ref="tree" :data="privilegeList" show-checkbox node-key="id" :default-checked-keys="jurisdictionId" :default-expand-all="true" :props="defaultProps" @check-change="getNode">
</el-tree>

methods: {
    // ID, ID
    getNode(data) {
        console.log("data", data.id);
    },
    // data
    getJurisdictionZtree() {
        this.$http.get(this.$api.privilege).then(res => {
        this.privilegeList = res.data.data.privilegeList;
        console.log("data", this.privilegeList);
      });
    }
}

clipboard.png

clipboard.png

clipboard.png

when the first picture is clicked to add, the following print corresponds to the parent node ID of the first image. The current click ID, cannot be stored through an empty array, but can only be stored
. The third picture is the data obtained from the data

.
Apr.05,2021
The

tree event function can have two parameters, one is val, and the other is node.
where node.parent is the parent information.


  • get the parent node: node.parent .
  • get ancestor node: loop through node.parent until the value is null .

data should have parent,. When I do it, I check pid directly. If there is, save

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e511c8-436bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e511c8-436bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?