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

Using streaming queries in MySQL to avoid data OOM

Table of contents 1. Introduction 2. JDBC impleme...

5 things to note when writing React components using hooks

Table of contents 01. Use useState when render is...

How to insert a link in html

Each web page has an address, identified by a URL...

A brief discussion on the problem of forgotten mysql password and login error

If you forget your MySQL login password, the solu...

Docker Compose installation and usage steps

Table of contents 1. What is Docker Compose? 2. D...

A brief discussion on MySQL B-tree index and index optimization summary

MySQL's MyISAM and InnoDB engines both use B+...

What are the benefits of using B+ tree as index structure in MySQL?

Preface In MySQL, both Innodb and MyIsam use B+ t...

Display mode of elements in CSS

In CSS, element tags are divided into two categor...

Detailed explanation of the use of find_in_set() function in MySQL

First, let’s take an example: There is a type fie...

Solve the MySQL 5.7.9 version sql_mode=only_full_group_by problem

MySQL 5.7.9 version sql_mode=only_full_group_by i...

Vue encapsulation component tool $attrs, $listeners usage

Table of contents Preface $attrs example: $listen...

Summary of ten Linux command aliases that can improve efficiency

Preface Engineers working in the Linux environmen...