vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.91k stars 1.19k forks source link

The relative positioning has not been realized. There is ambiguity with the document. #2046

Closed JenmingTang closed 11 months ago

JenmingTang commented 11 months ago

Vue version

3

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-1a2evq?file=src%2Frouter%2Findex.js

Steps to reproduce

vue-router@4 Relative redirection

//src\components\Profile.vue exited
const routes = [
  {
    path: '/users/:id/posts',
    redirect: to => {
      return 'profile'
    }
  },
  {
    path: '/users/:id/profile',
    component: () => import('@/components/Profile.vue')
  }
]

What is expected?

Below StackBlitz

https://vitejsvite1a2evq-4nhl--5173--6a615fc0.local-corp.webcontainer.io/users/123/posts
-->
https://vitejsvite1a2evq-4nhl--5173--6a615fc0.local-corp.webcontainer.io/users/123/profile

//The page has the parameter value of the past.

Below my project

According to the official website document, you should jump like this.

http://localhost:5173/users/123/posts
-->
http://localhost:5173/users/123/profile

What is actually happening?

Below StackBlitz

https://vitejsvite1a2evq-4nhl--5173--6a615fc0.local-corp.webcontainer.io/users/123/posts
-->
https://vitejsvite1a2evq-4nhl--5173--6a615fc0.local-corp.webcontainer.io/users/123/posts

//The page is blank. Nor did it not jump correctly.

But the fact is that it jumps like this. Prerequisition, I try to visit http://localhost:5173/users/123/profile too. It's well.

http://localhost:5173/users/123/posts
-->
http://localhost:5173/profile

System Info

System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz
    Memory: 2.08 GB / 15.84 GB
  Binaries:
    Node: 18.18.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.18362.449.0)

Any additional comments?

No response

posva commented 11 months ago

Duplicate of https://github.com/vuejs/router/issues/1902