Files
element-plus/docs/examples/mention/loading.vue
Noblet Ouways 2f17df1209 style(eslint-config): newline before import type (#21036)
* perf: change to import-x

* feat: add rules

* chore: fix rule

* chore: fix

* chore: fix

* chore: fix

* style: `pnpm lint:fix`

* Revert "style: `pnpm lint:fix`"

This reverts commit db0116a288.

* Revert "chore: fix"

This reverts commit 69c82a90c0.

* chore: fix

* style: `pnpm lint:fix`

* fix: lint

* chore: `pnpm format`
2025-06-16 15:37:12 +08:00

41 lines
854 B
Vue

<template>
<el-mention
v-model="value"
:options="options"
:loading="loading"
style="width: 320px"
placeholder="Please input"
@search="handleSearch"
/>
</template>
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import type { MentionOption } from 'element-plus'
const value = ref('')
const loading = ref(false)
const options = ref<MentionOption[]>([])
let timer: ReturnType<typeof setTimeout>
const handleSearch = (pattern: string) => {
if (timer) clearTimeout(timer)
loading.value = true
timer = setTimeout(() => {
options.value = ['Fuphoenixes', 'kooriookami', 'Jeremy', 'btea'].map(
(item) => ({
label: pattern + item,
value: pattern + item,
})
)
loading.value = false
}, 1500)
}
onBeforeUnmount(() => {
if (timer) clearTimeout(timer)
})
</script>