how to make reload in vue code example
Example 1: Vue.js force to reload re-render
this.$forceUpdate();
Example 2: how to reload automaticaly in vue
Vue.component('events', {
template: '#events-template',
data () {
return {
list: [],
timer: ''
}
},
created () {
this.fetchEventsList();
this.timer = setInterval(this.fetchEventsList, 300000);
},
methods: {
fetchEventsList () {
this.$http.get('events', (events) => {
this.list = events;
}).bind(this);
},
cancelAutoUpdate () {
clearInterval(this.timer);
}
},
beforeDestroy () {
this.cancelAutoUpdate();
}
});
new Vue({
el: 'body',
});