fixed #952
This commit is contained in:
parent
3842df9abe
commit
ddc35c9aaa
2 changed files with 30 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
|||
<Row>
|
||||
<i-col span="4">{{model}}</i-col>
|
||||
<i-col span="8">
|
||||
<i-select v-model="model" @input="handleInput" filterable remote :remote-method="remoteMethod" :loading="loading" clearable>
|
||||
<i-select v-model="model" :label="['L Alabama', 'L Hawaii']" multiple @input="handleInput" filterable remote :remote-method="remoteMethod" :loading="loading" clearable>
|
||||
<i-option v-for="option in options" :value="option.value" :key="new Date()">{{option.label}}</i-option>
|
||||
</i-select>
|
||||
</i-col>
|
||||
|
@ -13,7 +13,8 @@
|
|||
export default {
|
||||
data () {
|
||||
return {
|
||||
model: '',
|
||||
// model: 'Alabama',
|
||||
model: ['Alabama', 'Hawaii'],
|
||||
options: [
|
||||
|
||||
],
|
||||
|
@ -74,6 +75,7 @@
|
|||
]
|
||||
},
|
||||
remoteMethod (query) {
|
||||
console.log(13)
|
||||
if (query !== '') {
|
||||
this.loading = true;
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
type: [String, Number, Array],
|
||||
default: ''
|
||||
},
|
||||
label: {
|
||||
type: [String, Number, Array],
|
||||
default: ''
|
||||
},
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
|
@ -303,7 +307,6 @@
|
|||
},
|
||||
updateMultipleSelected (init = false, slot = false) {
|
||||
if (this.multiple && Array.isArray(this.model)) {
|
||||
// todo 这里的 label 有问题,另删除字符时也有问题
|
||||
let selected = this.remote ? this.selectedMultiple : [];
|
||||
|
||||
for (let i = 0; i < this.model.length; i++) {
|
||||
|
@ -584,6 +587,23 @@
|
|||
},
|
||||
mounted () {
|
||||
this.modelToQuery();
|
||||
// 处理 remote 初始值
|
||||
if (this.remote) {
|
||||
if (!this.multiple && this.model !== '') {
|
||||
this.selectToChangeQuery = true;
|
||||
if (this.label === '') this.label = this.model;
|
||||
this.lastQuery = this.label;
|
||||
this.query = this.label;
|
||||
} else if (this.multiple && this.model.length) {
|
||||
if (this.label.length !== this.model.length) this.label = this.model;
|
||||
this.selectedMultiple = this.model.map((item, index) => {
|
||||
return {
|
||||
value: item,
|
||||
label: this.label[index]
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.broadcastQuery('');
|
||||
});
|
||||
|
@ -687,6 +707,11 @@
|
|||
this.findChild(child => {
|
||||
child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
|
||||
});
|
||||
// remote下,设置了默认值,第一次打开时,搜索一次
|
||||
const options = this.$slots.default || [];
|
||||
if (this.query !== '' && !options.length) {
|
||||
this.remoteMethod(this.query);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.broadcast('Drop', 'on-update-popper');
|
||||
|
|
Loading…
Add table
Reference in a new issue