The prop `history` is marked as required in `Router` …
The prop `history` is marked as required in `Router`, but its value is `undefined`. in Router
解决办法:
出现这个报错是因为我用npm 安装的是react-router v4,react-router v4不再使用<Router history={hashHistory}>
这种方式定义history 实现类型。而是直接通过组件如BrowserRouter,HashRouter等
|
|
A ‘Router’ may have only one child element
react-router v4 在
解决办法:
用div 或者Switch 包裹所有Route
webpack 配置问题
v4 中引入<BrowserRouter>
组件, 而BrowserRouter使用的是HTML5 的history api, 在使用webpack-dev-server时会遇到
GET http://localhost:8080/xxx/xxx 404 (Not Found)
解决办法:
webpack.config.js中加入
然后将index.html中的bundle.js改为/bundle.js
|
|
参考:https://stackoverflow.com/questions/43209666/react-router-v4-cannot-get-url