【发布时间】:2018-12-10 05:58:37
【问题描述】:
我创建了一个新网站http://gk-chart.org/,并使用 react-rotuter-dom 添加了路由。
import {BrowserRouter as Router, Route, Switch} from "react-router-dom";
并将路由器添加为:-
<Switch>
<Route exact path="/" component={Home}></Route>
<Route path="/galery" component={Galery}></Route>
</Switch>
对于多种类型图表的嵌套路由,我在 Gallery 组件中添加了这些路由
<Route exact path={this.props.match.path} component={LineChart}></Route>
<Route path={`${this.props.match.path}/line`} component={LineChart}></Route>
<Route path={`${this.props.match.path}/lineChartFill`} component={LineChartFill}></Route>
<Route path={`${this.props.match.path}/lineChartComparision`} component={LineChartComparision}></Route>
<Route path={`${this.props.match.path}/lineChartComparisionFill`} component={LineChartComparisionFill}></Route>
路由器在点击链接时工作正常,但是当我尝试重新加载页面时,页面没有再次加载。
在图库页面http://gk-chart.org/galery 中存在多个嵌套路由,当我单击这些路由时,它们会正确加载,但是当我重新加载页面时,它不会加载。 请帮我解决这个问题。
【问题讨论】:
标签: javascript reactjs routing react-router-dom