react-router4.x有三种模式
* BrowserRouter
* HashRouter
* MemoryRouter
在使用HashRouter进行开发过程中,会遇到这个问题
Warning: hash history cannot push state it is ignored
解决办法是使用Object对象方式传参就可以了
this.props.history.push({ pathname: '/' }) // hashRouter (正确)
// this.props.history.push('/', {}) // BrowserRouter
哈哈哈哈,天生我才必有用!

本文探讨了在使用React Router的HashRouter模式时遇到的警告问题:'hashhistorycannotpushstateitisignored'。通过对比BrowserRouter的用法,指出了解决方案——使用Object对象的方式传参给history.push方法。
6864

被折叠的 条评论
为什么被折叠?



