父组件
<item
:todo="todo"
:func="deleteTodo"
v-for="todo in filteredTodos"
:key="todo.id"
/>
methods: {
deleteTodo(id) {
this.todos.splice(this.todos.findIndex(todo => todo.id === id), 1)
}
}
子组件:
props: {
todo: {
type: Object,
required: true
},
func:{
type:Function,
required:true
}
}