Answer the question
In order to leave comments, you need to log in
Disable router view cache?
The problem is this.
There is a Post and a list of recommendations in the sidebar.
We click on the sidebar, everything is OK, the post data has been changed, the cache works as it should.
We go to another page and then back to any page of the post, we get data from the cache that Vue updates, the result is clean data.
How to make vue router either update every time the post page or not update at all.
Now there is a watch listener for data substitution when switching to another post, however, when switching to a post from another page, say from a landing page, it processes the data request for the first time because it was like entering the page for the first time, and then it processes the listener that listens to the change in the post data . Since the last post is in Vuex, we updated it by going to the page, and then again through watch. This overwrites all the data that was from the previous post. For example, the user decided to hide the comments, of course, when going to any other post, regardless of which page, the comments should be hidden, but it turns out that they are not.
past_page.vue
<tempplate>
<post :details="postDetails"></post>
...
mounted(){
this.postDetails = loadPost(id);
....
post.vue
watch: {
currentPostDetails(oldUrl, newUrl) {
if (oldUrl === newUrl) {
return;
}
loadPost(id);
},
},
loadPost(id);
twice if the user navigated to the page home_page.vue
, for example, and then back to post.vue
which overwrites the saved data in vuex.<!-- <keep-alive>-->
<!-- <router-view :key="$route.path"></router-view>-->
<router-view></router-view>
<!-- </keep-alive>-->
Keep-alive
or :key="$route.path
they all break.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question