Vue routing relative path jumpToday I encountered multi-layer routing when writing something. A relative path is required when jumping between routes. Therefore, I checked the official website and found that the append attribute and router.resolve method were used, so I listed the specific usage methods. 1. Append attributeWhen the append attribute is set, the base path is added before the current (relative) path. Type: boolean Default value: false
If the current route is /eth, jump to the child /eth/block <router-link to="block" append> /eth =====> /eth/block </router-link> If the current route is /eth/login, jump to the same level /eth/block <router-link to="../block" append> /eth/login =====> /eth/block </router-link> If the current route is /eth/block, return to the previous level /eth <router-link to="../" append> /eth/block =====> /eth </router-link> 2.router.resolve methodrouter.resolve(location, current?, append?) Return value: route object
export default { mounted() { //Get the route object to be redirected let routeObj = this.$router.resolve({ path: '../' }, this.$route, "append" ); //Print and view the route object console.log(routeObj); //Route jump this.$router.push({ path: routeObj.route.path, query: { //Pass parameter id in this way: this.id } }); } } Vue router dynamic routing click jump path address repeated appendProblems encountered when practicing writing vue router dynamic routingWhen clicking multiple times, the address bar keeps adding duplicates. After checking the code, I found that the relative path in the page was missing a '/' at the beginning; adding it will display normally. as follows: 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:
|
<<: Detailed explanation of the principles and usage of MySQL stored procedures
>>: Steps to configure IIS10 under Win10 and support debugging ASP programs
After I found that the previous article solved th...
See the effect first Implementation Code <div ...
Sometimes we may encounter such a requirement, th...
Table of contents Typical waterfall website Water...
This article describes MySQL 8.0 user and role ma...
When Docker creates a container, it uses the brid...
This article shares the specific code of vue+echa...
--When connecting to the database, the matching r...
The project needs to use MySQL. Since I had alway...
The specific code for implementing the retractabl...
1. Rendering 2. Source code HTML < body > &...
1. Introduction to yum Yum (full name Yellow dogU...
Prepare the ingredients as shown above (ps: hadoo...
Table of contents 1. Problem 2. Solution 2.1 Pagi...
Scenario A recent requirement is an h5 page for m...