Skip to content

Reach Router

司徒正美 edited this page Jul 9, 2019 · 1 revision


    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <style>
      .aaa {
            width: 200px;
            height: 200px;
            background: red;
        }
       .bbb {
            width: 200px;
            height: 200px;
            background: lawngreen;
        }
    </style>
  <!--<script type='text/javascript' src="./dist/React.js"></script>-->
 <script src="./dist/React.js"></script>
 <script src="./dist/Router.js"></script>
 <script type='text/javascript' src="./lib/babel.js"></script>
    <script type='text/babel'>
var s

window.onload = function(){
       var {Router, Link, navigate} = ReachRouter
       //========  组件 =========
       const App = ({ children }) => (
        <div>
          <nav>
            <Link to="/">Home</Link> <Link to="dashboard">Dashboard</Link>
          </nav>
          <Router mode='hash'>
            <Home path="/"  />
            <Dashboard path="dashboard" />
          </Router>
        </div>
      );

      const Home = () => (
        <form >
          <h2>Welcome</h2>
        </form>
      );

      const Dashboard = () => (
        <div>
          <h2>Dashboard</h2>
        </div>
      );

ReactDOM.render(<App />, document.getElementById("root"));

}
    </script>



    <div id='root'></div>