问题
My database contains:
user: {
'monkey': 'banana',
'bear': 'fish'
}
Why does the event handler not execute?
let db = firebase.database();
let user = db.ref('user');
user.on('child_removed', (e) => {
console.log(e.val());
});
user.child('monkey').remove();
回答1:
This looks like some race going on with the code, because I tested and if you do something like this:
setTimeout(function() {
user.child('monkey').remove();
},2000);
it seems to work. Here is a fiddle I used to test it out, hope it helps:
http://jsfiddle.net/bgthp4wc/
来源:https://stackoverflow.com/questions/64740632/why-does-firebases-realtime-databases-child-removed-event-handler-not-execute