# @getaround-eu/use-route-params 中文文档

规范地址：https://npmcn.com/package/%40getaround-eu/use-route-params/

版本：1\.0\.4
npm 元数据更新时间：2023-01-05T15:30:13.635Z
中文译文更新时间：2026-11-16T14:17:50.689Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40getaround-eu/use-route-params
原文对照：https://npmcn.com/package/%40getaround-eu/use-route-params/?lang=original
源码仓库：https://github.com/drivy/use-route-params

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：7.1 kB，7 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react-router-dom ^6\.3\.0
- 首次发布：2022-07-11T15:23:52.061Z
- 最新版本发布：2023-01-05T15:30:13.514Z
- 近 30 天下载量：2041（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：6（近 12 个月 0 个）

## 中文简介

从路由中获取已键入参数的钩子

## 安装

```sh
npm install @getaround-eu/use-route-params
```

也可以使用：`pnpm add @getaround-eu/use-route-params`、`yarn add @getaround-eu/use-route-params`、`bun add @getaround-eu/use-route-params`

## README

# @ getaund- eu/ use- route- params (英语)

 [![license](https://badgen.net/npm/license/@getaround-eu/use-route-params)](https://github.com/drivy/use-route-params/blob/main/LICENSE)[![package version](https://badgen.net/npm/v/@getaround-eu/use-route-params)](https://npmjs.com/package/@getaround-eu/use-route-params)

从路径中获取您的参数

### 这是什么?

`useRouteParams` 是一个钩子,用来 [`react-router-dom v6`](https://github.com/remix-run/react-router/tree/main/packages/react-router-dom),允许您直接从提供的路由路径获取已键入的参数.

### 安装

假设你 **已经 `react-router-dom` 已安装**数字 :

```shell
yarn add @getaround-eu/use-route-params
# or
npm -i @getaround-eu/use-route-params
```

### 使用量

```typescript
import useRouteParams from "@getaround-eu/use-route-params"

const MY_COMPONENT_PATH = "/here/:is/:a/route/toMyComponent"


const MyComponent = () => {
  const { a, is } = useRouteParams(MY_COMPONENT_PATH)

  return (...)
}

// This way the route is always bound to the component
MyComponent.routePath = MY_COMPONENT_PATH

export default MyComponent

```

## 什么是Getaround吗?

绕道将安全、方便和负担得起的汽车与需要他们生活和工作的人连接起来. **我们的目标是创造世界最好的汽车共享市场 让共享的车辆比拥有它们更好**我们的社区包括依靠我们的汽车进行需求流动的人,以及在我们的平台上共用汽车的业主,包括经营自己的汽车共享业务的人.

我们的愿景是使我们的城市和社区拥有更好的生活环境:

-   增强人们的能力,方便地使用他们需要的汽车,无论何时需要这些汽车.
-   通过缓解拥堵,使公交更加便捷使用来改善流动性.
-   通过减少污染和推进可持续能源来保护我们的环境.

作为提醒,在大多数国家最大的碳排放者是汽车, 这就是我们在Getaround的影响.

你们可以 [在科技博客上更多地了解Getround](https://getaround.tech/about/)。 。 。 .

## 常见问题

### @getaround-eu/use-route-params 是什么？

从路由中获取已键入参数的钩子

### 如何安装 @getaround-eu/use-route-params？

在项目目录运行 npm install @getaround-eu/use-route-params，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react-router-dom（^6\.3\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @getaround-eu/use-route-params 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @getaround-eu/use-route-params 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @getaround-eu/use-route-params 可以商用吗？

@getaround-eu/use-route-params 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @getaround-eu/use-route-params 的下载量有多少？

根据 npm 官方下载统计，@getaround-eu/use-route-params 在 2026/10/17 – 2026/11/15 这 30 天内被下载 2,041 次，日均约 68 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @getaround-eu/use-route-params 还在维护吗？

最新版本 1\.0\.4 发布于 2023/01/05（3 年前）；至今共发布 6 个版本，其中过去 12 个月发布了 0 个；首次发布于 2022/07/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

