From: John Mao Date: Wed, 6 Mar 2024 23:57:19 +0000 (+0800) Subject: docs(zh): translate the currentRoute section of migration to Chinese (#2163) X-Git-Tag: v4.3.1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8618943e3c4e671da1ff3a32764a910db5835331;p=thirdparty%2Fvuejs%2Frouter.git 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 --- diff --git a/packages/docs/zh/guide/migration/index.md b/packages/docs/zh/guide/migration/index.md index a5deb815..12aa944e 100644 --- a/packages/docs/zh/guide/migration/index.md +++ b/packages/docs/zh/guide/migration/index.md @@ -113,15 +113,13 @@ router.resolve({ **原因**:Vue Router 不再使用 `path-to-regexp`,而是实现了自己的解析系统,允许路由排序并实现动态路由。由于我们通常在每个项目中只添加一个通配符路由,所以支持 `*` 的特殊语法并没有太大的好处。参数的编码是跨路由的,无一例外,让事情更容易预测。 - +### 现在 `currentRoute` 属性是一个 `ref()` -### The `currentRoute` property is now a `ref()` +路由器实例上的 [`currentRoute`](https://v3.router.vuejs.org/zh/api/#router-currentroute) 对象的属性在以前可以被直接访问。 -Previously the properties of the [`currentRoute`](https://v3.router.vuejs.org/api/#router-currentroute) object on a router instance could be accessed directly. +从 vue-router v4 开始,路由器实例上的 `currentRoute` 对象的底层类型已被改为 `Ref`,其源自 Vue 3 中新引入的[响应式基础](https://cn.vuejs.org/guide/essentials/reactivity-fundamentals.html)。 -With the introduction of vue-router v4, the underlying type of the `currentRoute` object on the router instance has changed to `Ref`, which comes from the newer [reactivity fundamentals](https://vuejs.org/guide/essentials/reactivity-fundamentals.html) introduced in Vue 3. - -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`: +当你使用 `useRoute()` 或 `this.$route` 获取路由信息时这并不会带来任何变化,如果想要直接在路由器实例上访问它,你需要通过 `currentRoute.value` 来访问实际的路由对象: ```ts const { page } = router.currentRoute.query // [!code --]