Files
element-plus/docs/examples/mention/loading.vue
赵添 0456c790db feat: add mention component (#17586)
* feat: add mention component

* fix: build error

* fix: build error

* feat: delete as a whole

* fix: update docs

* fix: update global.d.ts

* fix: update

* fix: update code

* fix: update code

* fix: update code

* fix: rename

* fix: update code

* fix: upload code

* fix: update code

* fix: fixed cursor position abnormality

* fix: update code

* fix: docs add avatar

* fix: tooltip position is wrong when placing on top

* feat: add overview icon

* fix: overview icon color
2024-08-02 11:00:26 +08:00

40 lines
849 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 { onBeforeMount, 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)
}
onBeforeMount(() => {
if (timer) clearTimeout(timer)
})
</script>