Solution for Vue routing this.route.push jump page not refreshing

Solution for Vue routing this.route.push jump page not refreshing

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

1. Background

Introduction: In the development of Vue projects, when using routing to jump to a page, the page to which the routing jumps is not refreshed.

That is, the vue life cycle function is not executed (created, mounted hook functions).

Examples:

Page A:

Page B:

question:

When you first click the button on page A to go to page B, everything is normal. When you return to page A and click the button again, page B does not execute the mounted hook function, resulting in the query method in the mounted function not being executed.

2. Solution:

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

2. Monitoring Routes

// Not recommended, poor user experiencewatch: {
	'$route' (to, from) {
    // The page refreshes when the route changes this.$router.go(0);
		}
},
// This method will request watch once more: {
	'$route' (to, from) {
    // The method executed in the mounted function, put it here this.qBankId = globalVariable.questionBankId;
	this.qBankName = globalVariable.questionBankTitle;
	this.searchCharpter();
	}
},

Vue this.$router.push route jump, refresh parameters disappear

this.$router.push({name:"",params:{id:""}})

name and params will disappear when refresh parameters are matched

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

Path and query are used together. The parameters will not disappear when the page is refreshed. The parameters in the query become part of the URL.

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • How to implement Vue click button route jump to specified page
  • vue jumps to the page and opens a new window, carrying and receiving parameters
  • Summary of the four common methods and differences of Vue jump page
  • How to implement page jump in Vue project
  • Vue implements automatic jump to login page when token expires
  • How to use vuex to jump to the page
  • How does Vue realize the jump between pages of this project

<<:  Detailed explanation of the solution to Ubuntu dual system stuck when starting

>>:  Navicat for MySql Visual Import CSV File

Recommend

W3C Tutorial (2): W3C Programs

The W3C standardization process is divided into 7...

W3C Tutorial (8): W3C XML Schema Activities

XML Schema is an XML-based alternative to DTD. XM...

How to hide elements on the Web and their advantages and disadvantages

Example source code: https://codepen.io/shadeed/p...

Implementation of static website layout in docker container

Server placement It is recommended to use cloud s...

Use simple jQuery + CSS to create a custom a tag title tooltip

Introduction Use simple jQuery+CSS to create a cus...

Linux platform mysql enable remote login

During the development process, I often encounter...

Summarize the common application problems of XHTML code

Over a period of time, I found that many people d...

Regarding the Chinese garbled characters in a href parameter transfer

When href is needed to pass parameters, and the p...

Some summary of MySQL's fuzzy query like

1. Common usage: (1) Use with % % represents a wi...

MySQL restores data through binlog

Table of contents mysql log files binlog Binlog l...

Essential skills for designing web front-end interfaces

[Required] UserInterface PhotoShop/Fireworks Desi...

How to create a table by month in MySQL stored procedure

Without going into details, let's go straight...

Cleverly use CSS3's webkit-box-reflect to achieve various dynamic effects

In an article a long time ago, I talked about the...

Detailed explanation of how to efficiently import multiple .sql files into MySQL

MySQL has multiple ways to import multiple .sql f...

How to recover accidentally deleted messages files in Linux

If there are files that are being used by a proce...