Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that Vue routing this.route.push jump page does not refresh

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article "Vue routing this.route.push jump page does not refresh how to solve the problem" most people do not understand, so the editor summed up the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "Vue routing this.route.push jump page does not refresh the problem how to solve" article.

Vue routing this.route.push jump page does not refresh I. background

Introduction: in vue project development, when routing is used for page jump, the page to which the route is redirected will not be refreshed.

That is, vue lifecycle functions are not executed (created, mounted hook functions).

Case study:

A page:

Page B:

Question:

When you first click the button on page A to page B, everything is fine. When you return to page An and click the button again, page B does not execute the mounted hook function. As a result, the query method in the mounted function is not executed.

2. Solution:

1. Use the activated: {} periodic function instead of the mounted: {} function.

2. Listen for routing

/ / not recommended, poor user experience watch: {'$route' (to, from) {/ / routing changes page refresh this.$router.go (0) }}, / / this method will request watch: {'$route' (to, from) {/ / the method executed in the mounted function, put there this.qBankId = globalVariable.questionBankId; this.qBankName = globalVariable.questionBankTitle; this.searchCharpter () }}, Vue this.$router.push route jumps, refresh parameter disappears this.$router.push ({name: ", params: {id:"}})

Refresh parameters will disappear with name and params.

This.$router.push ({path: ", query: {id:"}})

When path and query are matched, the refresh page parameters will not disappear, and the parameters in query become part of url.

The above is about "Vue routing this.route.push jump page does not refresh how to solve the problem" of this article, I believe we all have a certain understanding, I hope the content shared by the editor will be helpful to you, if you want to know more related knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 262

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report