index.html
<td>
<button type="button" class="btn btn-danger" @click ="onDelete(item._id)" >删除</button>
</td>
<script>
new Vue({
el:"#app",
data:{
movies:[]
},
methods:{
doDelete(id){
console.log(id)
this.movies = this.movies.filter(item=>item._id != id);
$.ajax({
url:"http://localhost:8080/doDelete",
method:"post",
data:{
id
}
}).then(res=>{
console.log(res)
})
}
}
</script>
index.js
//index.js
router.post("/doDelete",async ctx=>{
console.log(ctx.request.body);
var {id} = ctx.request.body;
await Top250Model.remove({_id:id})
})