# 错误：路由 "[param]" 具有无效的参数类型。参数必须是字符串或字符串数组，但收到了数字。

- **ID:** `nextjs/invalid-app-path-param-type`
- **领域:** nextjs
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

在动态路由（例如 app/[slug]/page.tsx）中，generateStaticParams 函数或来自路由的 params 对象为参数返回了非字符串值（例如数字），而 Next.js 期望该参数是字符串。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Next.js 13.x | active | — | — |
| Next.js 14.x | active | — | — |
| Next.js 15.x | active | — | — |

## 解决方案

1. ```
   Ensure generateStaticParams returns params as strings. Use String() or template literals to convert numbers.
   ```
2. ```
   Add TypeScript validation to ensure params are strings. Use a type guard or runtime check in the page component.
   ```

## 无效尝试

- **** — Next.js requires params to be strings for URL construction; numbers cause type errors. (90% 失败率)
- **** — TypeScript and runtime validation will throw an error if the value is not a string or array of strings. (60% 失败率)
- **** — The build will fail (if using static generation) or the route will not match correctly at runtime. (80% 失败率)
