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
In actual projects, the database needs to be back...
Introduction to temporary tables What is a tempor...
Recently, the company has put forward a requireme...
meta is an auxiliary tag in the head area of htm...
need Configuring DingTalk alarms in Zabbix is s...
1. Unzip mysql-8.0.21-winx64 2. Configure environ...
1. Demand The backend provides such data for the ...
Table of contents What is the slow query log? How...
Preface Everyone knows that many sites now charge...
When I was working on a project recently, I found...
1. To prohibit all IP addresses from accessing th...
Three Paradigms 1NF: Fields are inseparable; 2NF:...
Table of contents Project Directory Dockerfile Fi...
MySQL encryption and decryption examples Data enc...
I installed MySQL smoothly in Ubuntu 16.04 before...