react-router-dom失效
本想加个 nprogress 个,但是这里套上去之后 我的的路由组件的exact属性似乎全部不起作用了为什么?
主要代码如下:
class ProgressLoading extends React.Component {
componentWillMount() {
nprogress.start()
}
componentDidMount() {
nprogress.done()
}
render() {
return (
<Route exact {...this.props} />
)
}
}
const routerArray = [
{ path: '/logout', component: Logout },
{ path: '/index', component: IndexPage },
{ path: '/hotel', component: HotelList },
{ path: '/hotel/manage', component: HotelManage },
{ path: '/hotel/manage/roomType', component: RoomType },
{ path: '/hotel/manage/roomAdd', component: RoomAdd },
{ path: '/hotel/manage/roomPrice', component: RoomPrice },
{ path: '/customer', component: Customer },
{ path: '/customer/detail/:id', component: CustomerDetail },
{ path: '/replacement', component: Replacement },
{ path: '/replacement/manage', component: ReplacementManage },
{ path: '/replacement/add', component: ReplacementAdd },
{ path: '/replacement/manage/detail/:id', component: ReplacementDetail },
{ path: '/replacement/manage/edit/:id', component: ReplacementAdd },
{ path: '/order', component: Order },
{ path: '/order/detail', component: OrderDetail },
{ path: '/invoice', component: InvoiceTable },
{ path: '/invoice/:id', component: InvoiceManage },
{ path: '/logout', component: Logout },
{ path: '/logout', component: Logout }
]
const routerList = routerArray.map((props, i) => {
return <ProgressLoading {...props} key={i} />
});
const MainRouter = () => (
<Switch>
{
routerList
}
<Redirect from='*' to='/404' />
</Switch>
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论