Tree add check-directly prop

This commit is contained in:
梁灏 2019-02-27 10:22:01 +08:00
parent 98221c87b6
commit 467e2cf9a4
3 changed files with 21 additions and 211 deletions

View file

@ -41,6 +41,7 @@
export default {
name: 'TreeNode',
mixins: [ Emitter ],
inject: ['TreeInstance'],
components: { Checkbox, Icon, CollapseTransition, Render },
props: {
data: {
@ -156,7 +157,11 @@
},
handleSelect () {
if (this.data.disabled) return;
this.dispatch('Tree', 'on-selected', this.data.nodeKey);
if (this.TreeInstance.showCheckbox && this.TreeInstance.checkDirectly) {
this.handleCheck();
} else {
this.dispatch('Tree', 'on-selected', this.data.nodeKey);
}
},
handleCheck () {
if (this.data.disabled) return;

View file

@ -23,6 +23,9 @@
name: 'Tree',
mixins: [ Emitter, Locale ],
components: { TreeNode },
provide () {
return { TreeInstance: this };
},
props: {
data: {
type: Array,
@ -38,9 +41,14 @@
type: Boolean,
default: false
},
checkStrictly:{
type:Boolean,
default:false
checkStrictly: {
type: Boolean,
default: false
},
// showCheckbox checkDirectlyselect check
checkDirectly: {
type: Boolean,
default: false
},
emptyText: {
type: String
@ -54,7 +62,8 @@
},
render: {
type: Function
}
},
},
data () {
return {