寫一下我的做法
<a data-toggle="modal" data-target="#delete_tpl_modal" class="btn btn-default del" @click="ID=item.CustomerID"><i class="icon-remove"></i>刪除</a>
點擊刪除按鈕觸發模態框,同時通過@click事件將ID設置為當前的ID
var vm = new Vue({
el: "#container",
data:{
ID:null
}
methods:{
Delete_Customer_Data:function(){
this.$http.post('xxx',{CustomerID:this.ID}).then(function(response){
// 響應成功回調
if(response.data>0){
msg('1','刪除成功!');
this.Get_Customer_Data();
}else{
msg('3','刪除失敗!');
}
}, function(response){
// 響應錯誤回調
msg('3','刪除失敗!');
});
}
}
})
刪除的時候通過this.ID取得ID進行刪除
若有寫不明白的地方,望提出來,我再修改。
