Vue resource POST方式无法传参数。
<script>
new Vue({
el:"#ddd",
data:{
userList:""
},
mounted:function(){
this.getUser()
},
methods:{
getUser:function () {
var _this = this
this.$http.get('/getUsers').then(function(response){
_this.userList = response.body
// 响应成功回调
}, function(response){
alert("error")
// 响应错误回调
});
},
userId:function (index) {
var idd = this.$refs.p[index].innerHTML
this.$http.post('/delete',{id:idd},{emulateJSON : true }).then(function (value) {
alert(idd)
})
}
}
})
</script>
需要加上,{emulateJSON : true }
意思是: 将request body以application/x-www-form-urlencoded content type发送