Answer the question
In order to leave comments, you need to log in
I can't figure out how to implement reloading the page before going to it?
I have a page, the vue component is responsible for it, when you go to this page, data is loaded using getdataindex.
import axios from 'axios';
export default {
data:function(){
return{
subs:null,
posts:null,
tags:null,
}
},
methods:{
getdataindex:function () {
axios
.get('/api/getindexdata')
.then(response => {
this.subs = response.data.subs;
this.posts = response.data.posts;
this.tags = response.data.tags;
});
}
},
}
Answer the question
In order to leave comments, you need to log in
import axios from 'axios';
export default {
data:function(){
return{
subs:null,
posts:null,
tags:null,
}
},
beforeRouteEnter(_, __, next) {
axios.get('/api/getindexdata').then(response => {
next(vm => {
vm.subs = response.data.subs;
vm.posts = response.data.posts;
vm.tags = response.data.tags;
})
});
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question