mirror of
https://github.com/element-plus/element-plus.git
synced 2025-12-19 09:09:40 +08:00
* 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 commitdb0116a288. * Revert "chore: fix" This reverts commit69c82a90c0. * chore: fix * style: `pnpm lint:fix` * fix: lint * chore: `pnpm format`
41 lines
854 B
Vue
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>
|