我想我使用非常基本的反应路由器实现时遇到了问题。 当我加载我的“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;
你要确保你的服务器给你的index.html不管你求什么路径?没有散列,你需要服务器来支持它。如果您不想对服务器执行任何操作,请尝试使用哈希值。 – goldbullet
尝试在您的主页中添加一些<链接组件。点击此组件并将浏览器网址与您预期的网址进行比较。 – degr
我使用浏览器同步作为本地开发的服务器,我现在做了一项研究,发现我需要在浏览器同步选项中指定'connect-history-api-fallback',但它仍然无法工作。 。我是localhost中的服务器,并使用/ dist,因为我的依赖关系文件位于根目录中。@goldbullet –