Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd5d940

Browse files
committed
docs: 新增 getRoute 方法的文档,包含版本信息、功能描述及示例代码。
1 parent3e01dcf commitdd5d940

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

‎src/en/api/api.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ const router = getRouter();
127127
router.push('/hello');
128128
```
129129
130+
### getRoute
131+
132+
- **Version**:<VersionTag version="0.17.4" />
133+
134+
Return the current routing object information of the router. It is equivalent to using $route in the template syntax and is only applicable to vue-router 3.x.
135+
136+
Type definition:
137+
```ts
138+
getRoute():Route
139+
```
140+
141+
```ts
142+
import {getRoute }from'winjs';
143+
144+
exportconstgetCurrentRoute= ()=> {
145+
const route=getRoute();
146+
console.log('current route:',route?.path);
147+
returnroute;
148+
};
149+
```
150+
130151
### onBeforeRouteUpdate
131152
132153
Adds a navigation guard that is triggered whenever the current location is updated. Similar to`beforeRouteUpdate`, but can be used in any component. The guard is removed when the component is unmounted.

‎src/zh/api/api.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ const router = getRouter();
127127
router.push('/hello');
128128
```
129129
130+
### getRoute
131+
132+
- **版本**:<VersionTag version="0.17.4" />
133+
134+
返回路由器 router 的当前路由对象信息,相当于在模板语法中使用 $route,只适用于 vue-router 3.x。
135+
136+
类型定义如下:
137+
```ts
138+
getRoute():Route
139+
```
140+
141+
```ts
142+
import {getRoute }from'winjs';
143+
144+
exportconstgetCurrentRoute= ()=> {
145+
const route=getRoute();
146+
console.log('当前路由:',route?.path);
147+
returnroute;
148+
};
149+
```
150+
130151
### onBeforeRouteUpdate
131152
132153
添加一个导航守卫,不论当前位置何时被更新都会触发。类似于`beforeRouteUpdate`,但可以在任何组件中使用。当组件被卸载时,该守卫会被移除。

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp