未捕获的TypeError:无法读取属性' location'在ReactCompositeComponentWrapper._constructComponent WithoutOwner的新路由器上未定义

时间:2017-04-17 02:46:04

标签: reactjs react-router webpack-dev-server

我无法找到任何其他有关此错误的提及,我已尽力而为,我使用react-router,......可能是什么问题? 错误:

  

未捕获的TypeError:无法读取属性' location'未定义的       在新的路由器(eval at ./node_modules/react-router/es/Router.js(index.js:1),:36:52)       在ReactCompositeComponentWrapper._constructComponentWithoutOwner(eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js)   (index.js:1),:298:16)       在ReactCompositeComponentWrapper._constructComponent(eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js(index.js:1),   :285:19)       在ReactCompositeComponentWrapper.mountComponent(eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js(index.js:1),   :188:21)       在Object.mountComponent(eval at ./node_modules/react-dom/lib/ReactReconciler.js(index.js:1),   :46:35)       在ReactCompositeComponentWrapper.performInitialMount(eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js(index.js:1),   :371:34)       在ReactCompositeComponentWrapper.mountComponent(eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js(index.js:1),   :258:21)       在Object.mountComponent(eval at ./node_modules/react-dom/lib/ReactReconciler.js(index.js:1),   :46:35)       在mountComponentIntoNode(eval at ./node_modules/react-dom/lib/ReactMount.js(index.js:1),   :104:32)       在ReactReconcileTransaction.perform(eval at ./node_modules/react-dom/lib/Transaction.js(index.js:1),   :140:20)

1 个答案:

答案 0 :(得分:0)

你的反应路由器版本是什么? V3.0运行正常但是 react-router V4.0无法使用它  import { hashHistory } from 'react-router'

试试这个 import {Route, BrowserRouter as Router} from 'react-router-dom';