我正在尝试使用react路由器在我的模板中呈现一个组件但由于某种原因它无法正常工作。有人可以指出我在这段代码中犯的任何错误
'AppHeader'组件显示但'PostList'组件不
import {Meteor} from 'meteor/meteor';
import React, {Component} from 'react';
import {Router, Route, browserHistory, IndexRoute} from 'react-router';
import ReactDOM from 'react-dom'
import LandHeader from './components/header/landing-header';
import AppHeader from './components/header/app-header';
import PostList from './components/app/post_list';
import App from './components/app';
routes = (
<Router history={browserHistory}>
<Route path='/app' component={LandHeader}>
</Route>
<Route path='/' component={AppHeader}>
<IndexRoute component={PostList} />
</Route>
</Router>
)
Meteor.startup(()=>{
ReactDOM.render(routes, document.querySelector('.container'));
})
答案 0 :(得分:0)
你在{this.props.children}
渲染方法中有AppHeader
吗?
因为如果没有,它将无法工作。
它应该是这样的:
render() {
<div>
some stuff here
<div className='childrens'>{this.props.children}</div>
stuff here
</div>
}