Error message Navigating to current location ("/path") is not allowed Cause When the console displays the above message Error demonstration In order to demonstrate the error, a new project was rebuilt with <!-- vue template code --> <div> <button @click="gotoHandle">Test route jump</button> <input v-model="routeName"> <div> // Routing code export default { data() { return { routeName: '' } }, methods: { gotoHandle() { this.$router.push({name: this.routeName}) } } } Animated demo When you enter the same route repeatedly (whether by path or route name), you will be prompted that navigation to the current location ( WorkaroundMethod 1 Add export default { data() { return { routeName: '' } }, methods: { gotoHandle() { this.$router.push({name: this.routeName}).catch(error => error) } } } Method 2Add global error capture to the method that jumps to the error. import VueRouter from 'vue-router' const routerPush = VueRouter.prototype.push VueRouter.prototype.push = function (location) { return routerPush.call(this, location).catch(error => error) } The above code is the same when executed in The duplicate jump error of the Method 3This method is recommended. It is recommended to optimize the jump logic to avoid repeated jumps to the same route. This is the end of this article about the error cause and fix of Vue-router not allowing navigation to the current location (/path). For more related Vue-router navigation to the current location content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Analysis of the new features of MySQL 8.0 - transactional data dictionary and atomic DDL
Table of contents The pitfalls Filling method Wha...
Solve the problem of Chinese garbled characters i...
<meta name="viewport" content="...
Use the for loop to import the zabbix image into ...
Preface When my team was developing the tax syste...
Table of contents Effect display Component Settin...
This example takes the installation of Python 3.8...
1. The role of index In general application syste...
1. Create a user: Order: CREATE USER 'usernam...
1. Install MySQL # Download mysql in docker docke...
Table of contents 1. Resource download 2. Unzip t...
1. Version Information # cat /etc/system-release ...
<br />When we design web pages, we always en...
ylbtech_html_print HTML print code, support page t...
This article example shares the specific code of ...