The problem of vue route jump refresh

1. The problem arises:

When in use router-view, if you jump between the same routes, it will be used by default when the route is jumped 缓存策略, and the current routing component will not be refreshed. That is mounted, the beforeDestorywaiting hook function will not be triggered. If you want to force refresh, you can assign a unique key to it on the root route. Adopt $route.fullpathas its only key. In this way, Vue thinks that each internal route is a different route, and will force the component to be refreshed when jumping.

2. Problem solving:

Insert picture description here

3. Conclusion

In fact, there are many ways, such as passing v-if, $nexttickdestroying routes before and after, and so on. But personally feel that the above method is the most elegant.

Guess you like

Origin blog.csdn.net/qq_29722281/article/details/89134250