mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 17:31:02 +08:00
b8c38a9fe5
* chore: enhance eslint rules * chore: enhance eslint rules
98 lines
1.6 KiB
Vue
98 lines
1.6 KiB
Vue
<template>
|
|
<el-select-v2
|
|
v-model="value"
|
|
style="width: 240px"
|
|
multiple
|
|
filterable
|
|
remote
|
|
:remote-method="remoteMethod"
|
|
clearable
|
|
:options="options"
|
|
:loading="loading"
|
|
placeholder="Please enter a keyword"
|
|
/>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref } from 'vue'
|
|
|
|
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',
|
|
]
|
|
const list = states.map((item): ListItem => {
|
|
return { value: `value:${item}`, label: `label:${item}` }
|
|
})
|
|
|
|
interface ListItem {
|
|
value: string
|
|
label: string
|
|
}
|
|
|
|
const value = ref([])
|
|
const options = ref<ListItem[]>([])
|
|
const loading = ref(false)
|
|
|
|
const remoteMethod = (query: string) => {
|
|
if (query !== '') {
|
|
loading.value = true
|
|
setTimeout(() => {
|
|
loading.value = false
|
|
options.value = list.filter((item) => {
|
|
return item.label.toLowerCase().includes(query.toLowerCase())
|
|
})
|
|
}, 200)
|
|
} else {
|
|
options.value = []
|
|
}
|
|
}
|
|
</script>
|