a-tree-select组件的change修改有意义的事件名

This commit is contained in:
yaoyanan
2021-04-07 13:59:15 +08:00
parent 8065f765e3
commit 53a032bc97
4 changed files with 30 additions and 8 deletions
+10 -4
View File
@@ -53,10 +53,10 @@
required:false,
default:true
},
// value:{
// type: String,
// required: false
// },
value:{
// type: String,
required: false
},
placeholder:{
type: String,
default: '请选择',
@@ -262,12 +262,18 @@
},
onChange(value){
if(!value){
/*
* 使用$listeners向上暴露事件---和$emit一起使用出现的问题:change事件会执行两遍
* 解决办法:改变选中时提交的事件名*/
this.$emit('select-change', '');
this.treeValue = null
} else if (value instanceof Array) {
//多选
this.$emit('select-change', value.join(',').toString()) //修改第一次选中时,选中为空的情况
this.treeValue = value
} else {
//单选
this.$emit('select-change', value)
this.treeValue = value
}
},