mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
5844947198
* refactor(components): [select&select-v2] refactor components * refactor(components): [select-v2] * refactor(components): update * refactor(components): update * refactor(components): [select-v2] update * refactor(components): update * refactor(components): update * refactor(components): update type * refactor(components): update * refactor(components): update * refactor(components): update style * refactor(components): update docs * refactor(components): update * refactor(components): fix #15323 * refactor(theme-chalk): update * refactor(components): update * refactor(components): update * refactor(components): update * refactor(components): fix bugs * fix(components): fix issue * fix(components): update * fix(components): fix some bug * feat(components): update * feat(components): add tag slot * feat(components): update * fix(components): update * style(theme-chalk): update style * fix(theme-chalk): update * feat(theme-chalk): update * fix(components): update * feat: update * feat: update * feat: update * feat(components): update
135 lines
2.5 KiB
Vue
135 lines
2.5 KiB
Vue
<template>
|
|
<div class="flex flex-wrap">
|
|
<div class="m-4">
|
|
<p>default</p>
|
|
<el-select
|
|
v-model="value"
|
|
multiple
|
|
filterable
|
|
remote
|
|
reserve-keyword
|
|
placeholder="Please enter a keyword"
|
|
:remote-method="remoteMethod"
|
|
:loading="loading"
|
|
style="width: 240px"
|
|
>
|
|
<el-option
|
|
v-for="item in options"
|
|
:key="item.value"
|
|
:label="item.label"
|
|
:value="item.value"
|
|
/>
|
|
</el-select>
|
|
</div>
|
|
<div class="m-4">
|
|
<p>use remote-show-suffix</p>
|
|
<el-select
|
|
v-model="value"
|
|
multiple
|
|
filterable
|
|
remote
|
|
reserve-keyword
|
|
placeholder="Please enter a keyword"
|
|
remote-show-suffix
|
|
:remote-method="remoteMethod"
|
|
:loading="loading"
|
|
style="width: 240px"
|
|
>
|
|
<el-option
|
|
v-for="item in options"
|
|
:key="item.value"
|
|
:label="item.label"
|
|
:value="item.value"
|
|
/>
|
|
</el-select>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { onMounted, ref } from 'vue'
|
|
|
|
interface ListItem {
|
|
value: string
|
|
label: string
|
|
}
|
|
|
|
const list = ref<ListItem[]>([])
|
|
const options = ref<ListItem[]>([])
|
|
const value = ref<string[]>([])
|
|
const loading = ref(false)
|
|
|
|
onMounted(() => {
|
|
list.value = states.map((item) => {
|
|
return { value: `value:${item}`, label: `label:${item}` }
|
|
})
|
|
})
|
|
|
|
const remoteMethod = (query: string) => {
|
|
if (query) {
|
|
loading.value = true
|
|
setTimeout(() => {
|
|
loading.value = false
|
|
options.value = list.value.filter((item) => {
|
|
return item.label.toLowerCase().includes(query.toLowerCase())
|
|
})
|
|
}, 200)
|
|
} else {
|
|
options.value = []
|
|
}
|
|
}
|
|
|
|
const states = [
|
|
'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',
|
|
]
|
|
</script>
|