如何解决如何在下一个js中设置默认页面?
我是next.js
的新用户,在next.js
的{{1}}默认页面中,我想将其路径更改为index.js
,任何人都可以帮助我该怎么做?现在我正在使用login
,但它正在产生闪烁的问题,有人可以帮助解决此问题吗?
Router.push('/login');
解决方法
在 Next.config.js 中添加重定向配置,如下所示应该会有所帮助。
module.exports = {
async redirects() {
return [
{
source: '/about',destination: '/',permanent: true,},]
},}
,
从服务器端重定向;
export const getServerSideProps = async ({ res }) => {
res.setHeader("location",`/kiosk/welcome`);
res.statusCode = 302;
res.end();
return { props: {} };
};
const Index = () => <>Index</>;
export default Index;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。