如何在reactjs中将'/'设置为路由中的默认路径?

时间:2016-12-01 09:57:32

标签: reactjs url-routing react-routing

  

我已在api服务中发布了UI,但我想启动它   来自'/'的网址。但它是 http://localhost:8090/UI/   问题是在路由配置中我将路由设置为: -

internal::state:Entry

错误:/ UI /未在路由中定义。要解决此问题,我必须将路径更改为路径路径=“/ UI /”。如何将'/'设置为初始路径?

2 个答案:

答案 0 :(得分:0)

试试这个:

for re.MatchString(s)  {
    s = re.ReplaceAllString(s, "$1*$2")
}

答案 1 :(得分:0)

  

对我来说代码有效: -

import { Router,Route,IndexRoute, hashHistory, Link } from '../node_modules/react-router';

ReactDOM.render((
  <Router history={hashHistory}>
   <Route path="/" component={Login}/>
   <Route path="/main" component={main}>
     <IndexRoute component={Home} />
    <Route path = "/Accession" component = {Home} />
     <Route path="/contact" component={Contact}/>
 </Route>
  </Router>
), document.getElementById('App'));
  

因此,而不是browserHistory使用hashHistory