Skip to content

getStaticPath 返回值中的条目无效

InvalidGetStaticPathsEntry:getStaticPaths 返回的条目无效。期待一个对象,得到 ENTRY_TYPE

¥InvalidGetStaticPathsEntry: Invalid entry returned by getStaticPaths. Expected an object, got ENTRY_TYPE

¥What went wrong?

getStaticPaths 的返回值必须是一个对象数组。在大多数情况下,发生此错误是因为返回了数组的数组。使用 .flatMap().flat() 调用可能会有用。

¥getStaticPaths’s return value must be an array of objects. In most cases, this error happens because an array of array was returned. Using .flatMap() or a .flat() call may be useful.

pages/blog/[id].astro
export async function getStaticPaths() {
return [ // <-- Array
{ params: { slug: "blog" } }, // <-- Object
{ params: { slug: "about" } }
];
}

也可以看看:

¥See Also:

Astro 中文网 - 粤ICP备13048890号