我剛剛開始學習React並陷入了這個錯誤。React路由器:無法讀取未定義的屬性「路徑名」
Uncaught TypeError: Cannot read property 'pathname' of undefined at new Router
這裏是我的代碼:
var React = require('react');
var ReactDOM = require('react-dom');
var { Route, Router, IndexRoute } = require('react-router');
var hashHistory = require('react-router-redux')
var Main = require('./components/Main');
ReactDOM.render(
<Router history={hashHistory}>
<Route path="/" component={Main}>
</Route>
</Router>,
document.getElementById('app')
);
本教程,我以下用途做出反應,路由器2.0.0,但我的桌面上,我使用的是4.1.1。我嘗試搜索更改,但未能找到可行的解決方案。
"dependencies": {
"express": "^4.15.2",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"react-router-redux": "^4.0.8"
反應路由器 – WilomGfx
@WilomGfx 4.1.1的什麼版本?我說,我的版本在我的編輯中使用 –