我在反应中创建了一个简单的待办事项,我想在待办事项中删除所选任务。但是,当我运行此代码并尝试删除任何任务时,它会出错:
firebase.child失败:第一个参数是无效路径:" undefined"
componentWillMount: function() {
this.firebaseRef = new Firebase('https://simpletodosapp.firebaseio.com/todos');
var that = this;
this.firebaseRef.once('value', function(snapshot){
snapshot.forEach(function(data){
var todos = data.val();
todos['key'] = data.key;
that.setState({tasks: todos})
})
});
},
handleTodo: function(text) {
var newTask = this.state.tasks.concat(text)
this.firebaseRef.push(newTask)
this.setState({tasks: newTask})
},
handleDelete: function(task_id, key) {
this.firebaseRef.child(key).remove();
var remove = this.state.tasks.splice(task_id, 1);
this.setState({itasks: remove})
},