区别 | vue-router | react-router |
---|---|---|
改为history | mode: 'history' | 直接使用 react-router 的话,用 BrowserRouter 将<App> 包裹起来,或引入history(推荐,history可用于页面组件以外导航,此时就能够不用react-router-redux) |
npm install history
;import createHistory from 'history/createBrowserHistory'; const history = createHistory(); export default history;
组件内引用:vue
import history from './history';
组件内使用:react
history.push('/')
在任何地方只要引用 history 就可使用它进行导航操做,如 history.push('/')vue-router