Skip to content
司徒正美 edited this page Sep 5, 2017 · 1 revision
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">   
    <script src="./test/react.js"></script>
    <script src="./test/react-dom.js"></script>
    <script src="./node_modules/react-router-dom/umd/react-router-dom.js"></script>
    <script type='text/javascript' src="./lib/babel.js"></script>

  <script type='text/babel'>
  var s
  var i  = 100
  window.onload = function(){
      console.log(ReactRouterDOM)
      var {BrowserRouter, Link, Route} = ReactRouterDOM
      var Router = BrowserRouter
      const BasicExample = () => (
  <Router>
    <div>
      <ul>
        <li><Link to="/">Home</Link></li>
        <li><Link to="/about">About</Link></li>
        <li><Link to="/topics">Topics</Link></li>
      </ul>

      <hr/>

      <Route exact path="/" component={Home}/>
      <Route path="/about" component={About}/>
      <Route path="/topics" component={Topics}/>
    </div>
  </Router>
)

const Home = () => (
  <div>
    <h2>Home</h2>
  </div>
)

const About = () => (
  <div>
    <h2>About</h2>
  </div>
)

const Topics = ({ match }) => (
  <div>
    <h2>Topics</h2>
    <ul>
      <li>
        <Link to={`${match.url}/rendering`}>
          Rendering with React
        </Link>
      </li>
      <li>
        <Link to={`${match.url}/components`}>
          Components
        </Link>
      </li>
      <li>
        <Link to={`${match.url}/props-v-state`}>
          Props v. State
        </Link>
      </li>
    </ul>

    <Route path={`${match.url}/:topicId`} component={Topic}/>
    <Route exact path={match.url} render={() => (
      <h3>Please select a topic.</h3>
    )}/>
  </div>
)

const Topic = ({ match }) => (
  <div>
    <h3>{match.params.topicId}</h3>
  </div>
)
     s =  ReactDOM.render(<BasicExample />, document.getElementById("example"))
  }
  </script>

</head>

<body>

    <div>开发者工具</div>
    <div id='example'></div>

  
</body>

</html>