Skip to content

getStaticPaths 路由上缺少 params 属性。

GetStaticPathsExpectedParams:getStaticPaths 路由上所需的 params 属性缺失或为空。

¥GetStaticPathsExpectedParams: Missing or empty required params property on getStaticPaths route.

¥What went wrong?

getStaticPaths 指定的每个路由都需要 params 属性来指定匹配该路由所需的路径参数。

¥Every route specified by getStaticPaths require a params property specifying the path parameters needed to match the route.

例如,以下代码:

¥For instance, the following code:

pages/blog/[id].astro
---
export async function getStaticPaths() {
return [
{ params: { id: '1' } }
];
}
---

将创建以下路由:site.com/blog/1

¥Will create the following route: site.com/blog/1.

也可以看看:

¥See Also:

Astro 中文网 - 粤ICP备13048890号