vue-resource
vue-resource copied to clipboard
can't post the empty array
this code lost the empty array(tags:[])。just post the { id:1, isMain:true }
data () {
return {
form: {
tags[],
id:1,
isMain:true
}
}
}
methods: {
update () { //update
console.log(this.form) // { tags[], id:1, isMain:true }
//{ id:1, isMain:true }
this.$http.post('/operator/update', this.form).then((response) => {
// success
const res = response.body;
if (res.code==200) {
if(res.data.success){
this.$message(res.msg);
}else{
this.$message.error(res.data.message);
}
} else {
this.$message.error(res.msg);
}
}, (response) => {
// error
this.$message('error:' + response);
});
},
}
chrome 58.0.3029.110 vue2.x
I have the same problem. Is it the intended behavior ?
Guys, try debug this part of code when post data: https://github.com/pagekit/vue-resource/blob/60c1b71b17a958b3f035ae22ff045d34f2fe5878/dist/vue-resource.js#L439
I think it is a request issue:
https://stackoverflow.com/questions/9397669/jquery-ajax-jsonp-how-to-actually-send-an-array-even-if-its-empty