用react-router 的时候报这个warn:
bundle.js:22167 Warning: [react-router]
Router no longer defaults the history prop to hash history. Please use the
hashHistory singleton instead.
是不是说不支持直接写入hash格式的历史到浏览器历史中了?(感觉不是..
自己对这个错误理解的好像不是很对,想请有经验人士在帮助解释一下。
还有自己看Github上的示例有用到:
import useBasename from 'history/lib/useBasename'
// This helper is for setting basename on examples with minimal boilerplate. In
// an actual application, you would build a custom history to set basename.
export default function withExampleBasename(history, dirname) {
return useBasename(() => history)({ basename: `/${dirname}` })
}
之后
render((
<Router history={withExampleBasename(browserHistory, __dirname)}>
<Route path="/" component={App}>
<IndexRoute component={Index}/>
<Route path="/about" component={About}/>
<Route path="/users" component={Users}>
<IndexRoute component={UsersIndex}/>
<Route path=":id" component={User}/>
</Route>
</Route>
</Router>
), document.getElementById('example'))
以前用history这个包的时候也没有这样用过,想请经验人士帮助解释一下,感激不尽!
改成