Select: fix display issue of object-typed value in remote mode

pull/1606/head
Leopoldthecoder 2016-12-07 18:16:07 +08:00
parent 5cde77b37d
commit 3245232917
2 changed files with 4 additions and 1 deletions

View File

@ -121,6 +121,7 @@
created() { created() {
this.parent.options.push(this); this.parent.options.push(this);
if (this.parent.remote) this.parent.cachedOptions.push(this);
this.parent.optionsCount++; this.parent.optionsCount++;
this.parent.filteredOptionsCount++; this.parent.filteredOptionsCount++;
this.index = this.parent.options.indexOf(this); this.index = this.parent.options.indexOf(this);

View File

@ -183,6 +183,7 @@
data() { data() {
return { return {
options: [], options: [],
cachedOptions: [],
selected: this.multiple ? [] : {}, selected: this.multiple ? [] : {},
isSelect: true, isSelect: true,
inputLength: 20, inputLength: 20,
@ -337,7 +338,8 @@
}, },
getOption(value) { getOption(value) {
const option = this.options.filter(option => option.value === value)[0]; const option = (this.remote ? this.cachedOptions : this.options)
.filter(option => option.value === value)[0];
if (option) return option; if (option) return option;
const label = typeof value === 'string' || typeof value === 'number' const label = typeof value === 'string' || typeof value === 'number'
? value : ''; ? value : '';