Ric*_*ett 2 vue.js vue-resource
我有以下几点:
bidAmount: {
amount: 0
},
userToken: {
token: null
},
this.$http.post('/place-bet', this.bidAmount, function(response) {
alert(response);
});
Run Code Online (Sandbox Code Playgroud)
如何同时发送this.bidAmount和this.userToken
我已经尝试过了,但是发送不正确:
this.$http.post('/place-bet', [this.userToken, this.bidAmount], function(response) {
alert(response);
});
Run Code Online (Sandbox Code Playgroud)
您应该始终发布一个对象,这样您就可以使用它们各自的键访问服务器上的变量:
this.$http.post('/place-bet', {userToken: this.userToken, bidAmount: this.bidAmount}, function(response) {
alert(response);
});
Run Code Online (Sandbox Code Playgroud)
要么...
this.$http.post('/place-bet', {data:[this.userToken, this.bidAmount]}, function(response) {
alert(response);
});
Run Code Online (Sandbox Code Playgroud)