update Select
This commit is contained in:
parent
364aac0217
commit
89828b5b9c
2 changed files with 79 additions and 44 deletions
|
@ -1,45 +1,84 @@
|
||||||
|
<!--<template>-->
|
||||||
|
<!--<div>-->
|
||||||
|
<!--{{ model10 }} - -->
|
||||||
|
<!--{{ model11 }}-->
|
||||||
|
<!--<Select v-model="model10" style="width:260px">-->
|
||||||
|
<!--<Option v-for="(item, index) in cityList" :value="item.value" :key="index">{{ item.label }}</Option>-->
|
||||||
|
<!--</Select>-->
|
||||||
|
<!--<Select v-model="model11" style="width:260px">-->
|
||||||
|
<!--<Option v-for="(item, index) in cityList" :value="item.value" :key="index">{{ item.label }}</Option>-->
|
||||||
|
<!--</Select>-->
|
||||||
|
<!--</div>-->
|
||||||
|
<!--</template>-->
|
||||||
|
<!--<script>-->
|
||||||
|
<!--export default {-->
|
||||||
|
<!--data () {-->
|
||||||
|
<!--return {-->
|
||||||
|
<!--cityList: [],-->
|
||||||
|
<!--model10: '',-->
|
||||||
|
<!--model11: '',-->
|
||||||
|
<!--model12: ''-->
|
||||||
|
<!--}-->
|
||||||
|
<!--},-->
|
||||||
|
<!--mounted () {-->
|
||||||
|
<!--setTimeout(() => {-->
|
||||||
|
<!--this.cityList = [-->
|
||||||
|
<!--{-->
|
||||||
|
<!--value: 'beijing',-->
|
||||||
|
<!--label: '北京市'-->
|
||||||
|
<!--},-->
|
||||||
|
<!--{-->
|
||||||
|
<!--value: 'shanghai',-->
|
||||||
|
<!--label: '上海市'-->
|
||||||
|
<!--},-->
|
||||||
|
<!--{-->
|
||||||
|
<!--value: 'shenzhen',-->
|
||||||
|
<!--label: '深圳市'-->
|
||||||
|
<!--},-->
|
||||||
|
<!--{-->
|
||||||
|
<!--value: 'hangzhou',-->
|
||||||
|
<!--label: '杭州市'-->
|
||||||
|
<!--},-->
|
||||||
|
<!--{-->
|
||||||
|
<!--value: 'nanjing',-->
|
||||||
|
<!--label: '南京市'-->
|
||||||
|
<!--},-->
|
||||||
|
<!--{-->
|
||||||
|
<!--value: 'chongqing',-->
|
||||||
|
<!--label: '重庆市'-->
|
||||||
|
<!--}-->
|
||||||
|
<!--];-->
|
||||||
|
<!--}, 1000);-->
|
||||||
|
<!--}-->
|
||||||
|
<!--}-->
|
||||||
|
<!--</script>-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Select v-model="model1" style="width:200px">
|
<Select v-model="value">
|
||||||
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
|
<Option v-for="item in list" :value="item.value" :label="item.label" :key="item.value"></Option>
|
||||||
</Select>
|
|
||||||
<Select v-model="model2" style="width:200px">
|
|
||||||
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
|
|
||||||
</Select>
|
</Select>
|
||||||
|
<Button @click="setList">set list</Button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
cityList: [
|
value: '',
|
||||||
{
|
list: []
|
||||||
value: 'beijing',
|
|
||||||
label: '北京市'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'shanghai',
|
|
||||||
label: '上海市'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'shenzhen',
|
|
||||||
label: '深圳市'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'hangzhou',
|
|
||||||
label: '杭州市'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'nanjing',
|
|
||||||
label: '南京市'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'chongqing',
|
|
||||||
label: '重庆市'
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
model1: 'beijing',
|
methods: {
|
||||||
model2: 'shanghai'
|
setList () {
|
||||||
|
let list = [];
|
||||||
|
for (let i = 0; i < 400; i++) {
|
||||||
|
list.push({
|
||||||
|
value: 'value' + i,
|
||||||
|
label: 'label' + i
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.list = list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateOptions (init, slot = false) {
|
updateOptions (slot = false) {
|
||||||
let options = [];
|
let options = [];
|
||||||
let index = 1;
|
let index = 1;
|
||||||
|
|
||||||
|
@ -296,19 +296,15 @@
|
||||||
});
|
});
|
||||||
child.index = index++;
|
child.index = index++;
|
||||||
|
|
||||||
if (init) {
|
|
||||||
this.optionInstances.push(child);
|
this.optionInstances.push(child);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
if (init) {
|
|
||||||
if (!this.remote) {
|
if (!this.remote) {
|
||||||
this.updateSingleSelected(true, slot);
|
this.updateSingleSelected(true, slot);
|
||||||
this.updateMultipleSelected(true, slot);
|
this.updateMultipleSelected(true, slot);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
updateSingleSelected (init = false, slot = false) {
|
updateSingleSelected (init = false, slot = false) {
|
||||||
const type = typeof this.model;
|
const type = typeof this.model;
|
||||||
|
@ -635,7 +631,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.slotChange();
|
this.slotChange();
|
||||||
this.updateOptions(true, true);
|
this.updateOptions(true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 处理 remote 初始值
|
// 处理 remote 初始值
|
||||||
|
|
Loading…
Add table
Reference in a new issue