Select add defaultLabel prop
This commit is contained in:
parent
5be6584f09
commit
462eff37c5
1 changed files with 23 additions and 0 deletions
|
@ -177,6 +177,11 @@
|
||||||
type: [String, Number, Array],
|
type: [String, Number, Array],
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
|
// 4.4.0
|
||||||
|
defaultLabel: {
|
||||||
|
type: [String, Number, Array],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
multiple: {
|
multiple: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
@ -293,6 +298,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.checkUpdateStatus();
|
this.checkUpdateStatus();
|
||||||
|
|
||||||
|
// remote search, set default-label
|
||||||
|
if (this.remote && this.value && this.defaultLabel) {
|
||||||
|
if (!this.multiple) {
|
||||||
|
this.query = this.defaultLabel;
|
||||||
|
} else if (this.multiple && (this.defaultLabel instanceof Array) && this.value.length === this.defaultLabel.length) {
|
||||||
|
const values = this.value.map((item, index) => {
|
||||||
|
return {
|
||||||
|
value: item,
|
||||||
|
label: this.defaultLabel[index]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
this.$emit('on-set-default-options', JSON.parse(JSON.stringify(values)));
|
||||||
|
setTimeout(() => {
|
||||||
|
this.values = values;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue