mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
32 lines
747 B
Vue
32 lines
747 B
Vue
<script setup lang="ts">
|
|
const { data: users } = await useFetch('https://jsonplaceholder.typicode.com/users', {
|
|
key: 'typicode-users-email',
|
|
transform: (data: { id: number, name: string, email: string }[]) => {
|
|
return data?.map(user => ({
|
|
label: user.name,
|
|
value: String(user.id),
|
|
email: user.email,
|
|
avatar: { src: `https://i.pravatar.cc/120?img=${user.id}` }
|
|
}))
|
|
},
|
|
lazy: true
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<UInputMenu
|
|
:items="users"
|
|
icon="i-lucide-user"
|
|
placeholder="Select user"
|
|
:ui="{ content: 'min-w-fit' }"
|
|
>
|
|
<template #item-label="{ item }">
|
|
{{ item.label }}
|
|
|
|
<span class="text-muted">
|
|
{{ item.email }}
|
|
</span>
|
|
</template>
|
|
</UInputMenu>
|
|
</template>
|