我爲路由器設置如下代碼:陣營路由器V4不工作
import React from 'react';
import { Router, Route, browserHistory } from 'react-router';
import App from './App';
export default() => (
<Router history={browserHistory}>
<Route name="demo" path="/mydemo" component={App} />
</Router>
);
不過,我發現了以下錯誤:
Warning: Failed prop type: The prop `history` is marked as required in `Router`, but its value is `undefined`. in Router (at Router.js:12)
Uncaught TypeError: Cannot read property 'location' of undefined at new Router (Router.js:43)
你在哪裏填充'browserHistory'變量? –
剛剛從反應路由器中導入安裝了反應路由器的包作爲導入{Router,Route,browserHistory}後才導入; – Ramusesan
你使用的是什麼版本的react-router? – Nicholas