[英]React router 1.0.0-beta3 just doesnt work
Am I doing something wrong? 难道我做错了什么? this.props.children doesn't get rendered when i go to this URL http://localhost:7000/#/about
当我转到此URL http:// localhost:7000 /#/ about时,不会呈现this.props.children
--// file name: main.js -//文件名:main.js
import React from 'react';
import { Router, Route, Link } from 'react-router';
import { history } from 'react-router/lib/BrowserHistory';
import Wrapper from "./components/Wrapper.react";
import ThumbnailContainer from './components/ThumbnailContainer.react';
React.render((
<Router history={history}>
<Route path="/" component={Wrapper}>
<Route path="/about" components={ThumbnailContainer}>
</Route>
</Route>
</Router>
), document.body);
--//file name:Wrapper.react.js -//文件名:Wrapper.react.js
var Wrapper = React.createClass({
getInitialState: function() {
return(
{
className : "p-wrapper p-blue-theme"
}
);
},
render: function () {
return(
<div className={this.state.className} >
{this.props.children}
</div>
);
}
});
exports['default'] = Wrapper;
module.exports = exports['default'];
--// file name:ThumbnailContainer.react.js -//文件名:ThumbnailContainer.react.js
var React = require('react');
var ThumbnailContainer = React.createClass({
render: function(){
return (
<div className="p-thumbnail-container">
<a className="p-thumbnail" href="#">
<div className="p-thumbnail-img-container">
<img src="http://placehold.it/200x200" className="p-thumbnail-img" />
</div>
<div className="p-thumbnail-caption">
<h3 className="p-title">Thumbnail Title</h3>
<h4 className="p-sub-title">Thumbnail Sub Title</h4>
<p className="p-description">Thumbnail Description Lorem Ipsum</p>
</div>
</a>
</div>
);
}
});
module.exports = ThumbnailContainer;
将component = {ThumbnailContainer}更改为component = {ThumbnailContainer}。
Try removing the '/' from '/about'. 尝试从“ / about”中删除“ /”。 The route is nested so I believe that the leading '/' after the '/' default route is redundant.
该路由是嵌套的,因此我认为默认路由“ /”之后的前导“ /”是多余的。 Let us know if that works.
让我们知道是否可行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.