其他分享
首页 > 其他分享> > hash history cannot push state it is ignored

hash history cannot push state it is ignored

作者:互联网

react-router4.x有三种模式:

BrowserRouter
HashRouter
MemoryRouter

在使用HashRouter进行开发过程中,会遇到这个问题

Warning: hash history cannot push state it is ignored

hash模式下不能进行push state操作,解决办法是使用1,不使用2

this.props.history.push({ pathname: `${url}`, state: { nodeType: nodeType }}) //1
this.props.history.push(`${url}`, { nodeType: nodeType })  //2

标签:ignored,hash,state,push,nodeType,history
来源: https://www.cnblogs.com/GraceY/p/12186592.html