vuetify
vuetify copied to clipboard
feat: Add click events for VListItem prepend/append icon/avatars
markup
<template>
<v-app>
<div class="ma-4">
<v-list>
<v-list-item prependIcon="mdi-vuetify" @click:prepend="clickIcon(1)" @click="clickItem(1)" appendAvatar="https://cdn.vuetifyjs.com/images/lists/1.jpg" @click:append="clickAvatar(1)">List Item 1</v-list-item>
<v-list-item prependIcon="mdi-vuetify" @click:prepend="clickIcon(2)" @click="clickItem(2)" appendAvatar="https://cdn.vuetifyjs.com/images/lists/2.jpg" @click:append="clickAvatar(2)">List Item 2</v-list-item>
<v-list-item prependIcon="mdi-vuetify" @click:prepend="clickIcon(3)" @click="clickItem(3)" appendAvatar="https://cdn.vuetifyjs.com/images/lists/3.jpg" @click:append="clickAvatar(3)">List Item 3</v-list-item>
</v-list>
</div>
</v-app>
</template>
<script>
export default {
data: () => ({}),
methods: {
clickAvatar: (msg) => { console.log(`Avatar Clicked: ${msg}`)},
clickIcon: (msg) => { console.log(`Icon Clicked: ${msg}`)},
clickItem: (msg) => { console.log(`Item Clicked: ${msg}`)},
},
}
</script>
I think the idea was that if you want to do anything more than the default you should use the slot instead.
It does match VTextField, which as these handlers.
I think this should probably add these events as props similar to our input components:
https://github.com/vuetifyjs/vuetify/blob/97b22d2113dd2e1ae2ad162674aede4e79e92891/packages/vuetify/src/components/VField/VField.tsx#L79 https://github.com/vuetifyjs/vuetify/blob/97b22d2113dd2e1ae2ad162674aede4e79e92891/packages/vuetify/src/components/VInput/VInput.tsx#L50