我有带反应路由器的书包。当在新页面上重定向时,浏览器按钮(前一页/后一页)不起作用。我正在使用React + Mobx + TypeScript,webpack(TypeScript-React-Starter)
index.tsx
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import './index.scss';
ReactDOM.render(
<App />,
document.getElementById('root') as HTMLElement
);
registerServiceWorker();
App.tsx
import * as React from 'react';
import './App.scss';
import { HashRouter as Router, Redirect } from 'react-router-dom';
import { Route, Switch } from 'react-router';
import { DetailedWeather } from './components/detailedWeather/DetailedWeather';
import { Home } from './components/home/Home';
class App extends React.Component {
render() {
return (
<Router>
<main className="App">
<Switch>
<Route path={'/home'} render={({...props}) => <Home {...props} />}/>
<Route path={'/city/:id'} render={({...props}) => <DetailedWeather {...props} />}/>
<Redirect to="/home"/>
</Switch>
</main>
</Router>
);
}
}
export default App;