I have a vue component where I am populating an array by pushing a json object. The problem is that vue adds observer to the array which makes it impossible to iterate over. May be there is a better way to work with arrays in vuejs. I know that the observer is added to make objects reactive but in this case I do not know how to reach my data
My code:
app.js
require('./bootstrap');
window.Vue = require('vue');
import vueResource from 'vue-resource';
Vue.use(vueResource);
Vue.component('search', require('./components/Searchnames.vue'));
const a = new Vue({
el: '#app',
});
Search.vue
<template>
<div class="row">
<div class="col-md-5">
<a href='#' class='pointer_panel panel-link'>
<div class="panel panel-default panel-heading glow-border names">
{{names}}
</div>
</a>
</div>
</div>
</template>
<script>
export default {
data: function(){
return {
names: []
};
},
methods: {
getData: function(){
let self = this;
this.$http.jsonp(url, {jsonpCallback: "JSON_CALLBACK"})
.then(response=>{
console.log(response)
response.body.forEach(a => this.names.push(a))
})
}
},
mounted: function() {
this.getData()
console.log(this.names)
console.log(this.names.length)
console.log('Component mounted.')
}
}
</script>