땀모 2020. 2. 28. 04:33

1. 사진과 같은 부분에 deleteTask 매개변수받는 메서드를 만들어준다


2. 버튼클릭이벤트에 해당메서드를 삽입한다.

<button @click="deleteTask(index)" class="btn btn-danger">Delete</button>


3. delete 메서드 삭제 로직

deleteTask(index){

let confirmBox = confirm("정말로 삭제 하시겠습니까?");

if(confirmBox == true){

axios.delete(this.uri + this.tasks[index].id)
.then(response=>{

this.$delete(this.tasks, index);
}).catch(error=>{

console.log("Could not delete for some reason");

})
}

},


4. 확인