我正在使用对我的数据库的调用来检索一些结果并将它们推送到数组中。但是,当我console.log(this.activeBeers)
没有得到一个数组而是一个对象时。我怎样才能得到一个普通的数组而不是一个对象?
Vue.component('beers', {
template: '#beers-template',
data: function() {
return {
activeBeers: []
}
},
ready: function() {
function getActiveBeers(array, ajax) {
ajax.get('/getbeers/' + $('input#bar-id').val()).then(function (response) {
$.each(response.data, function(key, value) {
array.push(value.id);
});
}, function (response) {
console.log('error getting beers from the pivot table');
});
return array;
}
console.log(this.activeBeers = getActiveBeers(this.activeBeers, this.$http));
},
props: ['beers']
});