我有Cannot read property 'pathname' of undefined
at new Router
这个问题。我无法理解react-router 4
或我的代码中出现的问题。
var React = require('react');
var ReactDOM = require('react-dom');
var {Router} = require('react-router-dom');
var createHistory = require('history/createBrowserHistory');
var routes = require('./routes/routes');
debugger
// const history = createHistory();
ReactDOM.render((<Router history = {createHistory} routes = {routes} />), document.getElementById('app'));
这是在控制台中打印的内容:
Router.js:31 Uncaught TypeError: Cannot read property 'pathname' of undefined
at new Router (Router.js:31)
at ReactCompositeComponent.js:292
at measureLifeCyclePerf (ReactCompositeComponent.js:73)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (ReactCompositeComponent.js:291)
at ReactCompositeComponentWrapper._constructComponent (ReactCompositeComponent.js:282)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:185)
at Object.mountComponent (ReactReconciler.js:43)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:368)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:255)
at Object.mountComponent (ReactReconciler.js:43)
我无法弄清楚我错在哪里,请帮忙。