el-tree点击子节点,同时获取子节点和父节点的id

<el-tree
   class="filter-tree"
   :data="treeData"
   :props="defaultProps"
   default-expand-all
   :filter-node-method="filterNode"
   ref="tree"
   @node-click="clickTree"
   :style="{ height: ($store.state.clientHeight - 80) + 'px', color: '#fff', overflow: 'auto', backgroundColor: '#273947'}">
</el-tree>
clickTree(v, e) {
  console.log(v.id);
  console.log(e.parent.data.id);
}
data() {
    return {
        filterText: '',
        treeData: [
            {
                "id": "0",
                "label": "人员",
                "children": [
                    {
                        "id":"1",
                        "label":"省调用户(2)"
                    },
                    {
                        "id":"2",
                        "label":"地调用户(2)"
                    }
                ]
            }
        ],
        defaultProps: {
            "children": 'children',
            "label": 'label'
        }
}

打印结果:

打印结果

打印结果

猜你喜欢

转载自blog.csdn.net/weixin_43412413/article/details/99442006
今日推荐