docs(SelectMenu): improve async search example

This commit is contained in:
Benjamin Canac
2024-01-05 17:29:47 +01:00
parent 5d781112f1
commit e4b8fffc32
2 changed files with 25 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
<script setup>
const loading = ref(false)
const selected = ref([])
async function search (q) {
loading.value = true
const users = await $fetch('https://jsonplaceholder.typicode.com/users', { params: { q } })
loading.value = false
return users
}
</script>
<template>
<USelectMenu
v-model="selected"
:loading="loading"
:searchable="search"
placeholder="Search for a user..."
option-attribute="name"
multiple
trailing
by="id"
/>
</template>