【发布时间】:2017-10-19 17:06:06
【问题描述】:
我是 reactjs 的新手-在带有语言切换的网站上工作我正在尝试创建一个错误组件以用作 404 页面-但也尝试查看如何配置/自动切换网站以使用默认语言如果参数未定义或设置错误路径仍然监听 lang 参数。
router.js 目前看起来像这样
<Switch>
<Route exact path='/' render={() => (<Redirect to='/de/dienstleistungen/geistiges-eigentum' />)} />
<Route path='/:langURL/services' component={Services} />
<Route path='/:langURL/dienstleistungen' component={Services} />
<Route path='/services' component={Services} />
<Route path='/:langURL/how-it-works' component={HowItWorks} />
<Route path='/:langURL/anleitung' component={HowItWorks} />
<Route path='/:langURL/features' component={Features} />
<Route path='/:langURL/funktionen' component={Features} />
<Route path='/:langURL/beliebte-projekte' component={BundleDetails} />
<Route path='/:langURL/popular-projects' component={BundleDetails} />
<Route component={Error} />
</Switch>
【问题讨论】:
标签: javascript reactjs routes