Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyoung committed Jul 4, 2019
1 parent a8eb7e1 commit 02306f2
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
63 changes: 61 additions & 2 deletions examples/play/index.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,74 @@
<template>
<div style="margin: 20px;">
<el-input v-model="input" placeholder="请输入内容"></el-input>
<el-tree :data="data" :props="defaultProps" :highlight-current="true" node-key="id" @node-click="handleNodeClick" ref="dataTree"></el-tree>
<button @click="setCurrent">选中</button>
<button @click="clearCurrent">取消选中</button>
</div>
</template>

<script>
export default {
data() {
return {
input: 'Hello Element UI!'
data: [{
label: '一级 1',
id:1,
children: [{
label: '二级 1-1',
id:11,
children: [{
label: '三级 1-1-1'
}]
}]
}, {
label: '一级 2',
id:2,
children: [{
label: '二级 2-1',
id:21,
children: [{
label: '三级 2-1-1'
}]
}, {
label: '二级 2-2',
id:22,
children: [{
label: '三级 2-2-1'
}]
}]
}, {
label: '一级 3',
id:3,
children: [{
label: '二级 3-1',
id:31,
children: [{
label: '三级 3-1-1'
}]
}, {
label: '二级 3-2',
id:32,
children: [{
label: '三级 3-2-1'
}]
}]
}],
defaultProps: {
children: 'children',
label: 'label'
}
};
},
methods: {
handleNodeClick(data) {
console.log(data);
},
setCurrent(){
this.$refs.dataTree.setCurrentKey(1);
},
clearCurrent(){
this.$refs.dataTree.setCurrentKey(null);
}
}
};
</script>
2 changes: 1 addition & 1 deletion packages/tree/src/model/tree-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export default class TreeStore {

setCurrentNodeKey(key) {
if (key === null || key === undefined) {
this.currentNode && (this.currentNode.isCurrent = false);
this.currentNode.isCurrent = false;
this.currentNode = null;
return;
}
Expand Down

0 comments on commit 02306f2

Please sign in to comment.