转自:http://www.pianshen.com/article/3665136583/
<template>
<div>
<el-tree
:props="defaultProps"
:load="loadNode"
lazy
ref="tree"
show-checkbox
node-key="comcode" // 看项目和数据而定,有的为id
:check-strictly="true"
@check-change="handleClick"
@node-click="nodeClick"
>
</el-tree>
</div>
</template>
<script>
methods:{
handleClick(data, checked, node){
if(checked == true){
this.checkedId = data.comcode;
this.$refs.tree.setCheckedNodes([data]);
}
},
nodeClick(data,checked,node){
this.checkedId = data.comcode
this.$refs.tree.setCheckedNodes([data]);
}
}
</script>