For example, there is a component
Vue.component('News', { props: { data: { type: Object, default: function() { return { items: [] } } } }, created() { console.log('created'); return axios.get('/news/items') .then((response) => { console.log('data fetched'); this.data = response.data.News; }) .catch(function(error) { return Promise.reject(error.status); }); }, render: function(createElement) { console.log('render'); console.log(this.data.items); } }); By executing this code we get:
created render undefined //console.log(this.data.items); data fetched render (6) [{…}, {…}, {…}, {…}, {…}, {…}, __ob__: io] //console.log(this.data.items); Render worked twice, the first time without waiting for data from the ajax request. So actually how to make it work only after receiving these same data? Those. to become so:
created data fetched render