Skip to content

Commit f4289d3

Browse files
docs: fix relative redirect example (#2479)
1 parent 149aefa commit f4289d3

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

packages/docs/guide/essentials/redirect-and-alias.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ const routes = [
5454
path: '/users/:id/posts',
5555
redirect: to => {
5656
// the function receives the target route as the argument
57-
// a relative location doesn't start with `/`
58-
// or { path: 'profile'}
59-
return 'profile'
57+
return to.path.replace(/posts$/, 'profile')
6058
},
6159
},
6260
]

packages/docs/zh/guide/essentials/redirect-and-alias.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ const routes = [
5454
path: '/users/:id/posts',
5555
redirect: to => {
5656
// 该函数接收目标路由作为参数
57-
// 相对位置不以`/`开头
58-
// 或 { path: 'profile'}
59-
return 'profile'
57+
return to.path.replace(/posts$/, 'profile')
6058
},
6159
},
6260
]

0 commit comments

Comments
 (0)