有谁知道如何将 Next.js 中的任何特定页面定义为根(主页)?
我一直在网上查找,但找不到任何具体的解决方案。这应该是一个非常常见的用例。
还有另一篇文章,使用 Next.js next-routes,如何定义基本网页的主页路由?,但建议为其创建一个服务器。
有没有“NextJs”方式来设置主页?
提前致谢!
小智 28
这是nextjs提供的解决方案。
next.config.js在根目录中创建或编辑文件:
module.exports = {
async redirects() {
return [
{
source: '/',
destination: '/about',
permanent: true,
},
]
},
}Run Code Online (Sandbox Code Playgroud)
来源: https: //nextjs.org/docs/api-reference/next.config.js/redirects
| 归档时间: |
|
| 查看次数: |
34475 次 |
| 最近记录: |