我有以下内容:
bidAmount: {
amount: 0
},
userToken: {
token: null
},
this.$http.post('/place-bet', this.bidAmount, function(response) {
alert(response);
});
如何发送this.bidAmount
和this.userToken
我试过这个但是没有正确发送:
this.$http.post('/place-bet', [this.userToken, this.bidAmount], function(response) {
alert(response);
});
答案 0 :(得分:4)
您应该始终发布一个对象,这样您就可以使用各自的键访问服务器上的变量:
this.$http.post('/place-bet', {userToken: this.userToken, bidAmount: this.bidAmount}, function(response) {
alert(response);
});
...或
this.$http.post('/place-bet', {data:[this.userToken, this.bidAmount]}, function(response) {
alert(response);
});
答案 1 :(得分:1)
在数据对象中创建对象
new vue({
el:'#point'
data: {
newdata:{
token:'',
bidAmount:''
}
}
});
现在你可以
this.$http.post('/place-bet',this.newdata, function(response) {
alert(response);
});