请在reactjs代码中修复以下问题,代码来自reactjs教程

时间:2018-01-10 13:14:17

标签: reactjs

这是我在reactjs教程书2017中的reactjs代码

import React from 'react';
import ReactDOM from 'react-dom';
import {Router, Route, Link, browserHistory, IndexRoute } from 'react-router';

我已经将react-router安装到我的应用程序。

class App extends React.Component {
  render() {
    return (
      <div>
        <ul>
          <li>Home</li>
          <li>About</li>
          <li>Contact</li>
        </ul>
        {this.props.children}
      </div>
    );
  }
}
export default App;

export class Home extends React.Component {
  render() {
    return(
      <div>
        <h1>Home...</h1>
      </div>
    );
  }
}
// export default Home;

export class About extends React.Component {
  render() {
    return(
      <div>
        <h1>About...</h1>
      </div>
    );
  }
}
// export default About; /*****

export class Contact extends React.Component {
  render() {
    return(
      <div><h1>Contact...</h1></div>
    );
  }
}
// export default Contact; /*********
ReactDOM.render((
   <Router history = {browserHistory}>
      <Route path = "/" component = {App}>
         <IndexRoute component = {Contact} />
         <Route path = "home" component = {Home} />
         <Route path = "about" component = {About} />
         <Route path = "contact" component = {Contact} />
      </Route>
   </Router>


), document.getElementById('app'));

我有错误。

1 个答案:

答案 0 :(得分:0)

代码中没有错误,但版本有问题。 总之,它的依赖关系与项目代码不匹配。