VSelect - Select does not work with custom 'project' slot in Vuetify 3
P粉166779363
2023-08-26 12:35:37
<p>I'm using VSelect from Vuetify 3 in my Vue 3 application and I'm trying to use item slots. But my VSelect options become unselectable</p>
<p>I have this VSelect element: </p>
<pre class="brush:php;toolbar:false;"><v-select
v-model="tag"
:items="tags"
variant="solo"
label="Tags" >
<template #item="{ item }" >
<v-list>
<v-list-item :title="item.title" />
</v-list>
</template>
</v-select></pre>
<p>Tags and tags in data:</p>
<pre class="brush:php;toolbar:false;">tag: null,
tags: [
{ title: 'example1', value: 0 },
{ title: 'example2', value: 1 },
],</pre>
<p>In the output, I selected the option with the option, but the option is not selectable: </p>
<p>So how to set slot "item" using selectable options for VSelect component in Vuetify 3? </p>
The
props
object passed to the slot contains anonClick
callback, which you need to bind for selection to work:Documentation is a bit sparse at the moment, the type given is
Record
. In Vuetify 3.4, other values arekey
,title
,value
andref
(template reference from underlying VVritualScroll) Used to update the height of the scroll bar.When using a component with a
title
property (e.g. VListItem), you can bind the entireprops
object:(BTW, the
#item
slot has its content rendered into thev-list
, no need to wrap it again)This is a snippet: