Skip to content

Commit 8618943

Browse files
gophletJinjiang
andauthored
docs(zh): translate the currentRoute section of migration to Chinese (#2163)
* docs(zh): translate the currentRoute section of migration to Chinese * Apply suggestions from code review --------- Co-authored-by: Jinjiang <zhaojinjiang@me.com>
1 parent e7b3a6a commit 8618943

File tree

1 file changed

+4
-6
lines changed
  • packages/docs/zh/guide/migration

1 file changed

+4
-6
lines changed

packages/docs/zh/guide/migration/index.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,13 @@ router.resolve({
113113

114114
**原因**:Vue Router 不再使用 `path-to-regexp`,而是实现了自己的解析系统,允许路由排序并实现动态路由。由于我们通常在每个项目中只添加一个通配符路由,所以支持 `*` 的特殊语法并没有太大的好处。参数的编码是跨路由的,无一例外,让事情更容易预测。
115115

116-
<!-- TODO: translation -->
116+
### 现在 `currentRoute` 属性是一个 `ref()`
117117

118-
### The `currentRoute` property is now a `ref()`
118+
路由器实例上的 [`currentRoute`](https://v3.router.vuejs.org/zh/api/#router-currentroute) 对象的属性在以前可以被直接访问。
119119

120-
Previously the properties of the [`currentRoute`](https://v3.router.vuejs.org/api/#router-currentroute) object on a router instance could be accessed directly.
120+
从 vue-router v4 开始,路由器实例上的 `currentRoute` 对象的底层类型已被改为 `Ref<RouteLocationNormalizedLoaded>`,其源自 Vue 3 中新引入的[响应式基础](https://cn.vuejs.org/guide/essentials/reactivity-fundamentals.html)
121121

122-
With the introduction of vue-router v4, the underlying type of the `currentRoute` object on the router instance has changed to `Ref<RouteLocationNormalizedLoaded>`, which comes from the newer [reactivity fundamentals](https://vuejs.org/guide/essentials/reactivity-fundamentals.html) introduced in Vue 3.
123-
124-
While this doesn't change anything if you're reading the route with `useRoute()` or `this.$route`, if you're accessing it directly on the router instance, you will need to access the actual route object via `currentRoute.value`:
122+
当你使用 `useRoute()``this.$route` 获取路由信息时这并不会带来任何变化,如果想要直接在路由器实例上访问它,你需要通过 `currentRoute.value` 来访问实际的路由对象:
125123

126124
```ts
127125
const { page } = router.currentRoute.query // [!code --]

0 commit comments

Comments
 (0)