Vue之父組件向子組件傳方法

父組件

<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

}

 

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章