【发布时间】:2020-10-20 21:34:49
【问题描述】:
我找到 http://localhost:3000/#/admin 但我想在反应 16.8 中使用历史记录中的 createHashHistory 从 url 中删除 #
import createHashHistory from 'history/createHashHistory';
import { createStore, applyMiddleware, compose } from 'redux';
import { Provider } from 'react-redux';
import createSagaMiddleware from 'redux-saga';
import reducers from './redux/reducers';
import sagas from './redux/sagas';
const trackingId = 'UA-111111-1'; // Replace with your Google Analytics tracking ID
ReactGA.initialize(trackingId, {
debug: true,
});
// middlewared
const history = createHashHistory({ queryKey: false })
const sagaMiddleware = createSagaMiddleware();
const routeMiddleware = routerMiddleware(history);
const middlewares = [sagaMiddleware, routeMiddleware];
const store = createStore(reducers(history), compose(applyMiddleware(...middlewares)));
sagaMiddleware.run(sagas);
history.listen(location => {
console.log(location, 'location');
});
【问题讨论】: