【发布时间】:2021-07-02 14:56:45
【问题描述】:
我有下面的代码。它重定向到 /home 并传递一个电子邮件变量。但是,在地址栏中,它显示 http://localhost:4000/home?email=steverodgers@gmail.com。如何干净利落地使用 react 和 next.js 传递变量?
import { withRouter } from 'next/router'
authenticateUser(this.user)
.then(response => {
var email = response['email'];
if (email) {
this.props.router.push({
pathname: '/home',
query: { email: email}
});
}
});
【问题讨论】:
标签: reactjs routes react-router next.js push