I read on the docs : https://vuetifyjs.com/en/components/file-inputs#selection-slot
My code like this :
<v-file-input
v-model="files"
placeholder="Upload your documents"
label="File input"
multiple
prepend-icon="mdi-paperclip"
>
<template v-slot:selection="{ text }">
<v-chip
small
label
color="primary"
>
{{ text }}
</v-chip>
</template>
</v-file-input>
My codepen : https://codepen.io/positivethinking639/pen/vYONqKa?editable=true&editors=101
When upload 3 images and delete, it will delete all images. I want the user to be able to delete 1 image according to his choice. So the user can delete 1 picture
How can I do it?
Configure the chips to delete with a handler method.
Add 'close' attribute to v-chip
to get a close button on each file
Add a handler to the chip, passing index (and text if you want to prompt)
(optional) remove the clear-all button on VFileInput to prevent user confusion
Template
<v-file-input
...
:clearable="false"
>
<template v-slot:selection="{ index, text }">
<v-chip
...
close
@click:close="deleteChip(index, text)"
>
{{ text }}
</v-chip>
</template>
Component
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
files: [],
}),
methods: {
deleteChip(index, text) {
// Prompt here with text if required
this.files.splice(index, 1)
},
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With