0๐
I resolve this using vuefire
npm install vuefire firebase --save
Script:
import { setTimeout } from 'timers';
import { db } from '../config/db';
let booksRef = db.ref('data')
export default {
data: () => ({
books: []
}),
firebase: {
books: booksRef
},
methods: {
show(book) {
book.show = !(book.show);
},
deleteBook(book) {
debugger;
booksRef.child(book.id).remove();
}
},
The config db you can export from firebase.
- [Vuejs]-Use a variable throughout a Vue component?
- [Vuejs]-Title rendering accoding to image in vue js
0๐
this.$http.delete(`data/${book.id}.json`)
.then(response => {
return response
}.catch(err => {
// error callback
return err
})
this.$http.delete(`data/${book.id}.json`)
.then(() => {
const index = this.array.findIndex((i) => {
return i.id === id
})
if (index > -1) {
this.array.splice(index, 1)
}
}.catch(err => {
// error callback
return err
})
This worked for me, you could as well try it, or return a function that would delete it locally instead of just returning the response like the second example above
- [Vuejs]-Vue js text field value becomes empty when new row is appended
- [Vuejs]-Vue JS replacing orderBy filter with lodash
Source:stackexchange.com