我一直在关注本教程以获得React Router的工作https://scotch.io/tutorials/routing-react-apps-the-complete-guide ......但是当我尝试并利用反应路由器的任何功能时 - 它给我这个:react router - Router.js:111Uncaught TypeError:无法读取未定义的属性'getCurrentLocation'
Router.js:111Uncaught TypeError: Cannot read property 'getCurrentLocation' of undefined at Object.createTransitionManager (localhost:8080/public/bundle.js:22730:14) at Object.componentWillMount (localhost:8080/public/bundle.js:22737:36) at localhost:8080/public/bundle.js:15709:24 at measureLifeCyclePerf (localhost:8080/public/bundle.js:15436:13) at ReactCompositeComponentWrapper.performInitialMount (localhost:8080/public/bundle.js:15708:10) at ReactCompositeComponentWrapper.mountComponent (localhost:8080/public/bundle.js:15619:22) at Object.mountComponent (localhost:8080/public/bundle.js:8009:36) at ReactCompositeComponentWrapper.performInitialMount (localhost:8080/public/bundle.js:15732:35) at ReactCompositeComponentWrapper.mountComponent (localhost:8080/public/bundle.js:15619:22) at Object.mountComponent (localhost:8080/public/bundle.js:8009:36)
我试过使用webpack-dev-server以及...仍然没有喜悦 - 同样的问题。我找不到任何其他提及此错误的信息......可能是什么问题?
import React, { Component } from 'react';
import { render } from 'react-dom';
import {Router, Route} from 'react-router';
class Home extends Component {
render(){
return (<h1>Hello</h1>);
}
}
render(
<Router>
<Route path="/" component={Home}/>
</Router>,
document.getElementById('container')
);'
您使用的是包的版本是什么? (Check package.json) –
“react”:“^ 15.4.1”, “react-dom”:“^ 15.4.1”, “react-router”:“^ 3.0.0” “babel-core “:”^ 6.18.2“, ”babel-loader“:”^ 6.2.8“, ”babel-preset-es2015“:”^ 6.18.0“, ”babel-preset-react“:”^ “6.16.0”, “webpack”:“^ 1.13.3” – user3244268
不要紧,它是版本3.0.0的一部分,它需要传递一个历史记录选项...我已降级到2.8.1。暂时 – user3244268