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
<br />Original text: http://andymao.com/andy...
1: Installation command pip install docker-compos...
There is a new build tool in the Vue ecosystem ca...
This article example shares the specific code of ...
1. useState: Let functional components have state...
Vue front and back end ports are inconsistent In ...
Table of contents 1. Trigger Solution 2. Partitio...
Table of contents 1. Static implementation method...
Two major categories of indexes Storage engine us...
will-change tells the browser what changes will h...
How to determine what this points to? ①When calle...
Table of contents Start by clicking the input box...
Preface In backend development, in order to preve...
I just started learning about databases recently....
This article introduces common problems of Xshell...