notFound
notFound
函数允许您在路由段内渲染 not-found 文件
,并自动注入 <meta name="robots" content="noindex" />
标签。
notFound()
调用 notFound()
函数会抛出 NEXT_NOT_FOUND
错误并终止当前路由段的渲染。通过定义 not-found 文件,您可以在该路由段内优雅地显示未找到页面 (Not Found UI)。
须知:由于使用了 TypeScript 的
never
类型,调用notFound()
时无需写成return notFound()
。
版本历史
版本 | 变更说明 |
---|---|
v13.0.0 | 引入 notFound 功能。 |