mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 03:08:21 +08:00
feb169fe93
* feat(components): [select & select-v2] Add loading slot * feat(components): update
231 lines
4.8 KiB
Vue
231 lines
4.8 KiB
Vue
<template>
|
|
<div class="flex flex-wrap">
|
|
<div class="m-4">
|
|
<p>loading icon1</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"
|
|
/>
|
|
<template #loading>
|
|
<svg class="circular" viewBox="0 0 50 50">
|
|
<circle class="path" cx="25" cy="25" r="20" fill="none" />
|
|
</svg>
|
|
</template>
|
|
</el-select>
|
|
</div>
|
|
<div class="m-4">
|
|
<p>loading icon2</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"
|
|
/>
|
|
<template #loading>
|
|
<el-icon class="is-loading">
|
|
<svg class="circular" viewBox="0 0 20 20">
|
|
<g
|
|
class="path2 loading-path"
|
|
stroke-width="0"
|
|
style="animation: none; stroke: none"
|
|
>
|
|
<circle r="3.375" class="dot1" rx="0" ry="0" />
|
|
<circle r="3.375" class="dot2" rx="0" ry="0" />
|
|
<circle r="3.375" class="dot4" rx="0" ry="0" />
|
|
<circle r="3.375" class="dot3" rx="0" ry="0" />
|
|
</g>
|
|
</svg>
|
|
</el-icon>
|
|
</template>
|
|
</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())
|
|
})
|
|
}, 3000)
|
|
} 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>
|
|
|
|
<style>
|
|
.el-select-dropdown__loading {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100px;
|
|
font-size: 20px;
|
|
}
|
|
|
|
.circular {
|
|
display: inline;
|
|
height: 30px;
|
|
width: 30px;
|
|
animation: loading-rotate 2s linear infinite;
|
|
}
|
|
.path {
|
|
animation: loading-dash 1.5s ease-in-out infinite;
|
|
stroke-dasharray: 90, 150;
|
|
stroke-dashoffset: 0;
|
|
stroke-width: 2;
|
|
stroke: var(--el-color-primary);
|
|
stroke-linecap: round;
|
|
}
|
|
.loading-path .dot1 {
|
|
transform: translate(3.75px, 3.75px);
|
|
fill: var(--el-color-primary);
|
|
animation: custom-spin-move 1s infinite linear alternate;
|
|
opacity: 0.3;
|
|
}
|
|
.loading-path .dot2 {
|
|
transform: translate(calc(100% - 3.75px), 3.75px);
|
|
fill: var(--el-color-primary);
|
|
animation: custom-spin-move 1s infinite linear alternate;
|
|
opacity: 0.3;
|
|
animation-delay: 0.4s;
|
|
}
|
|
.loading-path .dot3 {
|
|
transform: translate(3.75px, calc(100% - 3.75px));
|
|
fill: var(--el-color-primary);
|
|
animation: custom-spin-move 1s infinite linear alternate;
|
|
opacity: 0.3;
|
|
animation-delay: 1.2s;
|
|
}
|
|
.loading-path .dot4 {
|
|
transform: translate(calc(100% - 3.75px), calc(100% - 3.75px));
|
|
fill: var(--el-color-primary);
|
|
animation: custom-spin-move 1s infinite linear alternate;
|
|
opacity: 0.3;
|
|
animation-delay: 0.8s;
|
|
}
|
|
@keyframes loading-rotate {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
@keyframes loading-dash {
|
|
0% {
|
|
stroke-dasharray: 1, 200;
|
|
stroke-dashoffset: 0;
|
|
}
|
|
50% {
|
|
stroke-dasharray: 90, 150;
|
|
stroke-dashoffset: -40px;
|
|
}
|
|
100% {
|
|
stroke-dasharray: 90, 150;
|
|
stroke-dashoffset: -120px;
|
|
}
|
|
}
|
|
@keyframes custom-spin-move {
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
</style>
|