javascript - 为什么 history.push 不会使用 react-router-dom 重定向到新组件?
问题描述
我有 2 个组件都完全相同。当我单击使用 react-bootstrap 创建的导航栏中的 Navlink 时,将重定向到一个。当我单击应该重定向到该组件的 html 按钮时,不会加载完全相同的另一个组件。请帮我。
html按钮和重定向功能看起来像
const getProfile = async (member) => {
// const addr = dispatch({ type: 'ADD_MEMBER', response: member })
console.log(member)
history.push('/member')
}
<button onClick={() => getProfile(p.publisher)}>Profile</button>
routes.js 看起来像
const Routes = (props) => {
return (
<Switch>
<Route path="/member" exact component={Member} />
</Switch>
)
}
export default Routes
我尝试重定向到的组件与我从导航链接单击它时重定向到并正在工作的组件完全相同
解决方案
推荐阅读
- reactjs - 如何在 DevOps 中根据其发布阶段设置变量?
- delphi - 如何使用 Postman 向 Datasnap 服务器发送多个值
- css - 如何将字符串添加到 Django 模板?
- android - 尝试在真实设备上运行实时视频时,Exoplayer 显示空白屏幕
- javascript - 控制台日志返回 null
- scala - scala 中的“不符合 trait Builder 的类型参数界限”是什么意思?
- python - python中的字符串是可变的,如果不解释这个?
- android - 证明开源 Android
- c# - 验证几个字段不重复
- python - 如何“创建环境变量文件:touch .env 进行配置(在项目根目录中)。”