react-router 4 使用history(go、push等操作)、浏览器回退、前进无法切换路由

新手上路,请多包涵
class App extends Component {
  render() {
    return (
      <Provider {...store}>
        <HashRouter basename="/">
          <Layout/>
        </HashRouter>
      </Provider>
    );
  }
}

Layout内部的代码

<Layout.Content className='content'>
  <Routes />
</Layout.Content>

Routes代码

import React from 'react';
import loadable from 'react-loadable';
import { Switch, Route } from 'react-router-dom';

import Home from './page/home.jsx';

const AsyncGroup = loadable({
  loader: () => import(
    /* webpackChunkName: "group" */
    './page/group.jsx'
  ),
  loading: Loading,
});
function Loading() {
  return <div>Loading.....</div>;
}
const Routes = () => (
  <Switch>
    <Route exact path="/" component={Home} />
    <Route path="/group" component={AsyncGroup} />
    {/* <Redirect from="*" to="/404" /> */}
  </Switch>
);

export default Routes;

使用Link可以正常切换路由,上面提到的操作无法切换

clipboard.png

请问,router.history是否是Router内的history,
为什么Link可以让两者同时变化,上面的操作却不行

阅读 7.8k
宣传栏