我用react-router开发我的项目. 下面是我的代码. const App2 = React.createClass({ render() { return ( div Link to="index"index/Link Link to="favorite"favorite/Link Link to="myPage"myPage/Link {this.props.children} /div ) }});var
下面是我的代码.
const App2 = React.createClass({ render() { return ( <div> <Link to="index">index</Link> <Link to="favorite">favorite</Link> <Link to="myPage">myPage</Link> {this.props.children} </div> ) } }); var app = ReactDOM.render ( <Router history={browserHistory}> <Route path="/" component={App2}> <Route path="index" component={PhotoFeedWrapper}/> <Route path="favorite" component={FavoriteWrapper}/> <Route path="myPage" component={MyPageWrapper}/> </Route> </Router>, document.getElementById('app') );
我认为我的代码是正确的.但是,这会像下面一样呈空.
<div id="app"><!-- react-empty: 1 --></div>
没有脚本错误.
我做错了什么?
链接组件目前仅支持绝对路径.你必须改为:<Link to="/index">index</Link> <Link to="/favorite">favorite</Link> <Link to="/myPage">myPage</Link>