【发布时间】:2018-12-11 13:25:37
【问题描述】:
我需要通过 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},而是使用this.data...应该可以解决问题:)