首页 > 解决方案 > 两个巢反应路线如何正确?

问题描述

import { Route,  BrowserRouter as Router, Switch } from 'react-router-dom'

<Router weId={`${this.props.weId || ''}_wfcgvw`} basename={`${parentPath}/e10`}>
          <Route weId={`${this.props.weId || ''}_1jvdgd`} exact path={`/index`} component={ME10Index} />
          <Route weId={`${this.props.weId || ''}_1jvdgd`} path={`/invoice`} component={ME10Invoice} />
          <Route weId={`${this.props.weId || ''}_1jvdgd`} path={`/statistic`} component={ME10Statistic} />
          <Route weId={`${this.props.weId || ''}_cg92wc`} exact path={'/mine'}component={ME10Mine} />
          <Route weId={`${this.props.weId || ''}_cg92wc`} exact path={'/mine/mail'} component={ME10MailSetting} />
</Router>

如您所见,我有一个像这样的路由器,我想优化这部分:

<Route weId={`${this.props.weId || ''}_cg92wc`} exact path={'/mine'}component={ME10Mine} />
<Route weId={`${this.props.weId || ''}_cg92wc`} exact path={'/mine/mail'} component={ME10MailSetting} />

<Route weId={`${this.props.weId || ''}_ucqhv6`} path="/mine">
            <Route weId={`${this.props.weId || ''}_cg92wc`} path={''}component={ME10Mine} />
            <Route weId={`${this.props.weId || ''}_cg92wc`} path={'mail'} component={ME10MailSetting} />
</Route>

很快,我想使路线简短并包含嵌套信息。怎么做?谢谢。

标签: reactjsreact-router

解决方案


推荐阅读