React路由器不工作
React router not working
我有一个简单的react路由器设置。请在这里查看我的代码-
https://github.com/rocky-jaiswal/lehrer-node/tree/master/frontend
这是react路由器最基本的设置,但在浏览器中我无法使其工作-
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route } from 'react-router';
import IndexContainer from './components/index-container';
import AboutContainer from './components/about-container';
import PagesContainer from './components/pages-container';
(function main() {
ReactDOM.render((
<Router>
<Route path="/" component={IndexContainer}>
<Route path="about" component={AboutContainer} />
<Route path="pages" component={PagesContainer} />
</Route>
</Router>),
document.getElementById('app')
);
})();
问题还在于控制台上没有报告错误。即使我更改了URL,IndexComponent也始终被挂载。如果我输入http://localhost:3333/#/about它更改为http://localhost:3333/#/about?_k=bac2pt以某种方式并停留在IndexComponent上。
我的简单webpack配置或react/areact路由器的版本是否有问题?
谢谢,Rocky
IndexContainer
是您的父组件,请尝试在render()
中添加{ this.props.children }
,以便显示AboutContainer
和PagesContainer
。
相关文章:
- AngularJS UI路由器不能像ng路由器那样工作
- 流星铁路由器动态段不工作
- 当名称空间在id参数之前声明时,Angular UI路由器停止工作
- angular ui路由器不工作
- 无法获取用户 ID 路由参数以在反应路由器中继上工作
- ExpressJS路由器不工作
- 铁:路由器工作很奇怪 - 将我发送到模板然后返回
- Angular (1.5.0) ng 路由器不工作
- ng-controller工作,UI路由器:控制器不是
- UI 路由器不加载 rawgit 中的视图,但在本地工作
- 如何在Microsoft IIS上使用反应路由器(createBrowserHistory)使路由工作
- React路由器不工作
- angular ui路由器状态模板不工作
- 使用react路由器,redux将无法工作
- 具有url参数的角度状态/路由器不工作
- 为什么angularjs路由器在这里不工作
- Angular UI路由器工作不正常
- 骨干路由器是'工作不正常
- 无法让UI路由器在我的Angular Framework中工作
- 我的主干js路由器是't工作