我需要通过axios将Vue Instance的完整数据对象发送到后端。这是我的代码。
var vm = new Vue({
el: '#el',
delimiters: ["[[", "]]"],
data: {
brand: 0,
model: 0,
country: "europe",
},
created: function () {
},
updated: function () {
axios.post('http://localhost:81/lnt/public/member/car_result', {data: this.data})
.then(function (response) {
});
}
});
当我console.log(this.data);
我得到一个未定义的输出当我尝试
axios.post('http://localhost:81/lnt/public/member/car_result', {brand: this.brand})
我可以发送品牌但需要立即发送整个数据阵列
要获得整个data
对象,你必须使用this.$data
updated: function () {
axios.post('http://localhost:81/lnt/public/member/car_result', {data: this.$data})
.then(function (response) {
//do something
});
}