[英]React.js Route not working properly
my /
route doesn't properly render my main component. 我的
/
路线无法正确渲染我的主要组件。
Her is my code: 她是我的代码:
ReactDOM.render(
<Router history={browserHistory}>
<Route path="/" componenet={Main}>
<IndexRoute component={Index}></IndexRoute>
<Route path="portfolio" component={Portfolio}></Route>
</Route>
</Router>,
document.getElementById('app')
);
This is my Main component: 这是我的主要组成部分:
export default class Main extends React.Component {
render() {
console.log("asdfasfsaf");
return(
<div>
<h1> This is Main Page </h1>
{this.props.children}
</div>
)
}
}
Once i load the website it doesn't console log anything nor render <h1>
This is main page header. 一旦我加载了网站,它就不会控制台日志,也不会呈现
<h1>
这是主页标题。 Also If I delete this Main
componenet it still goes to my IndexRoute
without any error which is my index componenet. 另外,如果我删除此
Main
componenet,它仍会转到我的IndexRoute
而没有任何错误,这就是我的索引componenet。
Try this: 尝试这个:
ReactDOM.render((
<Router history={browserHistory}>
<Route path="/" componenet={Main}>
<IndexRoute component={Index}></IndexRoute>
<Route path="portfolio" component={Portfolio}></Route>
</Route>
</Router>,
), document.getElementById('app'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.