我认为使用非常基本的反应路由器实现时遇到了问题。 当我加载“localhost:8080 / dist /”时,它工作,加载正在App上导入的标题组件,并正确加载IndexRoute,但是当我尝试访问时localhost:8080 / dist / FPDV0200“或”localhost:8080 / dist / FPDV0400“它dosnt工作。有线索吗?
app.component.tsx
import * as React from 'react';
import Header from '../header/header.component';
class App extends React.Component<any, any> {
render() {
return (
<div id="app">
<Header />
<div>
{this.props.children}
</div>
</div>
);
}
}
export default App;
app.component.tsx
import * as React from 'react';
import { Router, hashHistory, Route, IndexRoute } from 'react-router';
import App from '../components/structure/app/app.component';
import Home from '../pages/home/home';
import FPDV0200 from '../pages/FPDV0200/FPDV0200';
import FPDV0400 from '../pages/FPDV0400/FPDV0400';
const routes = (
<Router history={hashHistory}>
<Route path="/" component={App}>
<IndexRoute component={Home}/>
<Route path="FPDV0200" component={FPDV0200}/>
<Route path="FPDV0400" component={FPDV0400}/>
</Route>
</Router>
);
export default routes;
答案 0 :(得分:1)
localhost:8080/dist/FPDV0200
- 如果使用browserHistory,此网址应该有效。
您使用hashHistory,因此您的网址应如下所示
localhost:8080/dist#FPDV0200