@lottie
To delete images from firestore using a Vue.js component, you can follow these steps:
1 2 |
import firebase from 'firebase/app'; import 'firebase/firestore'; |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
methods: { deleteImage(imageId) { const db = firebase.firestore(); db.collection('images').doc(imageId).delete() .then(() => { console.log("Image deleted successfully"); }) .catch((error) => { console.error("Error deleting image: ", error); }); } } |
1
|
<button @click="deleteImage(image.id)">Delete Image</button> |
Make sure to replace 'images'
with the name of the collection where your images are stored and adjust the document structure in the doc(imageId)
call based on your Firestore data structure.
By following these steps, you should be able to delete images from Firestore in your Vue.js component.