How to get the selected item of v-list in vuetify3 #16400
-
In vuetify2 there was the v-list-item-group offering the v-model prop. How is this done in vuetify3?
doesn't work. |
Beta Was this translation helpful? Give feedback.
Answered by
santiagoaloi
Jan 12, 2023
Replies: 2 comments 1 reply
-
You only need Playground reproduction: <template>
<v-app>
<v-main>
<code> {{ selected }} </code>
<v-card class="mx-auto" max-width="300">
<v-list v-model:selected="selected" density="compact">
<v-list-subheader>REPORTS</v-list-subheader>
<v-list-item
v-for="(item, i) in items"
:key="i"
:value="item"
active-color="primary"
>
<template v-slot:prepend>
<v-icon :icon="item.icon"></v-icon>
</template>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item>
</v-list>
</v-card>
</v-main>
</v-app>
</template>
<script setup>
import { ref } from 'vue'
const selected = ref([])
const items = ref( [
{ text: 'Real-Time', icon: 'mdi-clock' },
{ text: 'Audience', icon: 'mdi-account' },
{ text: 'Conversions', icon: 'mdi-flag' },
])
</script> |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Kugeleis
-
Thanks. It would be great if this could be explained in the docs. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You only need
v-model:selected="..."
in v3Playground reproduction:
https://shorturl.at/nqV45