fixed #1865
This commit is contained in:
parent
8c4cc38379
commit
e1b86bcf73
3 changed files with 102 additions and 17 deletions
|
@ -53,32 +53,112 @@
|
||||||
<!--}-->
|
<!--}-->
|
||||||
<!--</script>-->
|
<!--</script>-->
|
||||||
|
|
||||||
|
<!--<template>-->
|
||||||
|
<!--<div>-->
|
||||||
|
<!--<Select v-model="value">-->
|
||||||
|
<!--<Option v-for="item in list" :value="item.value" :label="item.label" :key="item.value"></Option>-->
|
||||||
|
<!--</Select>-->
|
||||||
|
<!--<Button @click="setList">set list</Button>-->
|
||||||
|
<!--</div>-->
|
||||||
|
<!--</template>-->
|
||||||
|
<!--<script>-->
|
||||||
|
<!--export default {-->
|
||||||
|
<!--data () {-->
|
||||||
|
<!--return {-->
|
||||||
|
<!--value: '',-->
|
||||||
|
<!--list: []-->
|
||||||
|
<!--}-->
|
||||||
|
<!--},-->
|
||||||
|
<!--methods: {-->
|
||||||
|
<!--setList () {-->
|
||||||
|
<!--let list = [];-->
|
||||||
|
<!--for (let i = 0; i < 400; i++) {-->
|
||||||
|
<!--list.push({-->
|
||||||
|
<!--value: 'value' + i,-->
|
||||||
|
<!--label: 'label' + i-->
|
||||||
|
<!--});-->
|
||||||
|
<!--}-->
|
||||||
|
<!--this.list = list;-->
|
||||||
|
<!--}-->
|
||||||
|
<!--}-->
|
||||||
|
<!--}-->
|
||||||
|
<!--</script>-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div style="width: 400px;margin: 50px;">
|
||||||
<Select v-model="value">
|
<div>data: {{ model13 }}</div>
|
||||||
<Option v-for="item in list" :value="item.value" :label="item.label" :key="item.value"></Option>
|
<Row>
|
||||||
|
<Col span="12" style="padding-right:10px">
|
||||||
|
<Select
|
||||||
|
v-model="model13"
|
||||||
|
filterable
|
||||||
|
remote
|
||||||
|
:remote-method="remoteMethod1"
|
||||||
|
:loading="loading1">
|
||||||
|
<Option v-for="(option, index) in options1" :value="option.value" :key="index">{{option.label}}</Option>
|
||||||
</Select>
|
</Select>
|
||||||
<Button @click="setList">set list</Button>
|
</Col>
|
||||||
|
<Col span="12">
|
||||||
|
<Select
|
||||||
|
v-model="model14"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
remote
|
||||||
|
:remote-method="remoteMethod2"
|
||||||
|
:loading="loading2">
|
||||||
|
<Option v-for="(option, index) in options2" :value="option.value" :key="index">{{option.label}}</Option>
|
||||||
|
</Select>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
value: '',
|
model13: '',
|
||||||
list: []
|
loading1: false,
|
||||||
|
options1: [],
|
||||||
|
model14: [],
|
||||||
|
loading2: false,
|
||||||
|
options2: [],
|
||||||
|
list: ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New hampshire', 'New jersey', 'New mexico', 'New york', 'North carolina', 'North dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode island', 'South carolina', 'South dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West virginia', 'Wisconsin', 'Wyoming']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setList () {
|
remoteMethod1 (query) {
|
||||||
let list = [];
|
if (query !== '') {
|
||||||
for (let i = 0; i < 400; i++) {
|
this.loading1 = true;
|
||||||
list.push({
|
setTimeout(() => {
|
||||||
value: 'value' + i,
|
this.loading1 = false;
|
||||||
label: 'label' + i
|
const list = this.list.map(item => {
|
||||||
|
return {
|
||||||
|
value: item,
|
||||||
|
label: item
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
this.options1 = list.filter(item => item.label.toLowerCase().indexOf(query.toLowerCase()) > -1);
|
||||||
|
}, 200);
|
||||||
|
} else {
|
||||||
|
this.options1 = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
remoteMethod2 (query) {
|
||||||
|
if (query !== '') {
|
||||||
|
this.loading2 = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.loading2 = false;
|
||||||
|
const list = this.list.map(item => {
|
||||||
|
return {
|
||||||
|
value: item,
|
||||||
|
label: item
|
||||||
|
};
|
||||||
|
});
|
||||||
|
this.options2 = list.filter(item => item.label.toLowerCase().indexOf(query.toLowerCase()) > -1);
|
||||||
|
}, 200);
|
||||||
|
} else {
|
||||||
|
this.options2 = [];
|
||||||
}
|
}
|
||||||
this.list = list;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,14 @@
|
||||||
queryChange (val) {
|
queryChange (val) {
|
||||||
const parsedQuery = val.replace(/(\^|\(|\)|\[|\]|\$|\*|\+|\.|\?|\\|\{|\}|\|)/g, '\\$1');
|
const parsedQuery = val.replace(/(\^|\(|\)|\[|\]|\$|\*|\+|\.|\?|\\|\{|\}|\|)/g, '\\$1');
|
||||||
this.hidden = !new RegExp(parsedQuery, 'i').test(this.searchLabel);
|
this.hidden = !new RegExp(parsedQuery, 'i').test(this.searchLabel);
|
||||||
|
},
|
||||||
|
// 在使用函数防抖后,设置 key 后,不更新组件了,导致SearchLabel 不更新 #1865
|
||||||
|
updateSearchLabel () {
|
||||||
|
this.searchLabel = this.$el.innerHTML;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.searchLabel = this.$el.innerHTML;
|
this.updateSearchLabel();
|
||||||
this.dispatch('iSelect', 'append');
|
this.dispatch('iSelect', 'append');
|
||||||
this.$on('on-select-close', () => {
|
this.$on('on-select-close', () => {
|
||||||
this.isFocus = false;
|
this.isFocus = false;
|
||||||
|
|
|
@ -627,6 +627,7 @@
|
||||||
this.$nextTick(() => this.broadcastQuery(''));
|
this.$nextTick(() => this.broadcastQuery(''));
|
||||||
} else {
|
} else {
|
||||||
this.findChild((child) => {
|
this.findChild((child) => {
|
||||||
|
child.updateSearchLabel(); // #1865
|
||||||
child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
|
child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue