【发布时间】:2021-09-01 10:32:00
【问题描述】:
第一页和页面中的React路由器链接标签也发生了变化,但在第二页有很多链接如果我点击这个链接它可以更改链接但不能更改正文我该如何修复它... 路由器代码:
<Switch>
<Route exact strict path="/">
<Home />
</Route>
<Route exact strict path="/about/">
<About />
</Route>
<Route exact strict path="/channel/:title" component={withRouter(Dashboard)} />
</Switch>
</div>
</Router>
第二页代码
function Dashboard() {
const { title } = useParams();
return (
<div>
<Play
title={title}
/>
</div>
);
}
通过 props 传递一些数据
//this is <Play/> component code just showing here shortly
<Router>
<VideoPlayer
controls={true}
src={this.state.link}
poster={this.state.poster}
width={window.screen.width}
height={window.screen.height - (window.screen.width+100)}
/>
<Link to="/channel/Rtv">Rtv</Link>
</div>
</Router>
只显示这段代码的一小部分... 请帮助我...我该如何解决这个错误
完整代码在这里: https://gist.github.com/fahadali32/8643d33a2328c1375552e4ba7637fc92
【问题讨论】:
-
您可能需要发布一个完整的示例(例如 GitHub 存储库或 gist),因为您显示的代码看起来还不错。还要检查 JavaScript 控制台中的错误消息,这些消息可能会揭示出问题所在。
-
好的,我会做的,请帮帮我...
-
请检查一下...
标签: reactjs react-router react-router-component