码迷,mamicode.com
首页 > 其他好文 > 详细

React-Router #03 Link

时间:2018-10-15 18:24:47      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:log   dom   route   span   err   reac   about   classname   exp   

import React, { Component } from ‘react‘;
import logo from ‘./logo.svg‘;
import ‘./App.css‘;
import About from ‘./About‘;
import Home from ‘./Home‘;

import {
  BrowserRouter as Router,
  Route,
  Link
} from ‘react-router-dom‘

// import Link from ‘react-router-dom/Link‘;

class App extends Component {
  render() {
    return (
      <Router>
        <div className="App">
          <header className="App-header">
            <img src={logo} className="App-logo" alt="logo" />
            <h1 className="App-title">Welcome to React</h1>
          </header>
          <div className="App-intro">
            <ul>
              <li><Link to="/">Home</Link></li>
              <li><Link to="/about">About</Link></li>
              <li><Link to="/error">Error</Link></li>
            </ul>
            <Route path="/" component={ Home } />
            <Route path="/about" component={ About } />
            <Route path="/home" component={ Home } />
          </div>
        </div>
      </Router>
    );
  }
}

export default App;

React-Router #03 Link

标签:log   dom   route   span   err   reac   about   classname   exp   

原文地址:https://www.cnblogs.com/xufeimei/p/9792076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!