在使用element-ui中tree的checkbox时,有时需要根据节点的属性来决定是否在节点前显示checkbox选择框,因此需要对element-ui的源码进行修改。
1、将node_modules文件夹中 element-ui 文件夹的 packages 中的 tree 文件夹复制出来。

2、修改 tree-node.vue文件,在<el-checkbox></el-checkbox>标签中修改 v-if 的内容

3、使用自定义的tree组件
import elTree2 from './tree/src/tree.vue'
<elTree2
:data="baselayerTree"
:props="treeProps"
@check-change="handleNodeClick"
:show-checkbox="true"
:check-strictly="true">
</elTree2>

4、效果

网友评论