update Select example

This commit is contained in:
梁灏 2017-11-09 11:11:54 +08:00
parent 67a9c1cc4b
commit 4b338397ce
2 changed files with 3 additions and 57 deletions

View file

@ -168,13 +168,7 @@
<!--</script>--> <!--</script>-->
<template> <template>
<div> <div style="width: 300px">
{{ model10 }}
<Select v-model="model10" multiple style="width:260px">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
----------
{{ model14 }}
<Select <Select
v-model="model14" v-model="model14"
multiple multiple
@ -184,67 +178,22 @@
:loading="loading2"> :loading="loading2">
<Option v-for="(option, index) in options2" :value="option.value" :key="index">{{option.label}}</Option> <Option v-for="(option, index) in options2" :value="option.value" :key="index">{{option.label}}</Option>
</Select> </Select>
<Button @click="clear">clear</Button>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
cityList: [
{
value: 'beijing',
label: '北京市'
},
{
value: 'shanghai',
label: '上海市'
},
{
value: 'shenzhen',
label: '深圳市'
},
{
value: 'hangzhou',
label: '杭州市'
},
{
value: 'nanjing',
label: '南京市'
},
{
value: 'chongqing',
label: '重庆市'
}
],
model10: [],
model13: '', model13: '',
loading1: false, loading1: false,
options1: [], options1: [],
model14: [], model14: [],
loading2: false, loading2: false,
options2: [], 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'] list: ['a', 'b', 'c']
} }
}, },
methods: { methods: {
remoteMethod1 (query) {
if (query !== '') {
this.loading1 = true;
setTimeout(() => {
this.loading1 = false;
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) { remoteMethod2 (query) {
if (query !== '') { if (query !== '') {
this.loading2 = true; this.loading2 = true;
@ -261,9 +210,6 @@
} else { } else {
this.options2 = []; this.options2 = [];
} }
},
clear () {
this.model14 = [];
} }
} }
} }

View file

@ -54,7 +54,7 @@
import { oneOf, findComponentDownward } from '../../utils/assist'; import { oneOf, findComponentDownward } from '../../utils/assist';
import Emitter from '../../mixins/emitter'; import Emitter from '../../mixins/emitter';
import Locale from '../../mixins/locale'; import Locale from '../../mixins/locale';
import {debounce} from './utils'; import { debounce } from './utils';
const prefixCls = 'ivu-select'; const prefixCls = 'ivu-select';