我有一个反应项目,它在开发版本中运行良好,但是当我导出它(bundle.js)并将它带到tomcat时,它无法识别react-router-dom的路由。
我需要在tomcat中配置一些东西吗?我找到了几个例子,但它们对我没用:
react routing is able to handle different url path but tomcat returns 404 not available resources
https://github.com/gildata/RAIO/issues/138
这是我的index.jsx:
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import { IntlProvider } from 'react-intl';
import { Provider } from 'react-redux';
import store from 'src/app/store';
import App from 'src/app/App';
render(
<Provider store={store}>
<IntlProvider locale="en">
<BrowserRouter>
<App />
</BrowserRouter>
</IntlProvider>
</Provider>,
document.getElementById('contenedor'),
);
&#13;
这是App.jsx
import React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';
import Login from 'src/app/Login';
import Menu from 'src/app/Menu';
const logueado = localStorage.getItem('tLogueado');
const App = () => (
<main>
<Switch>
<Route exact path="/login" render={() => (logueado ? (<Redirect to="/onix" />) : (<Login />))} />
<Route exact path="/onix" render={() => (logueado ? (<Menu />) : (<Redirect to="/login" />))} />
</Switch>
</main>
);
export default App;
&#13;
我做错了什么?请耐心等待我的反应。
答案 0 :(得分:0)
有两种方法可以解决此问题
或
<BrowserRouter basename="/calendar"/>