直接上图
效果图如下:
代码图:
//组件 <el-tree :data="treeData" show-checkbox default-expand-all node-key="id" ref="tree" @node-click="handleTreeClick" :expand-on-click-node="false" :check-strictly="true" highlight-current @check="handleTreeChange" :props="defaultProps" > </el-tree>
//方法
handleTreeChange(data, list) { this.form = data; //暂存选中节点 // console.log(data); this.$refs.tree.setCheckedKeys([]); //删除所有选中节点 this.$refs.tree.setCheckedNodes([this.form]); //选中已选中节点 },