React-Router #03 Link
Posted xufeimei
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了React-Router #03 Link相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章
Storybook w/ react-router - 你不应该在 <Router> 之外使用 <Link>
[react-router] React-Router的<Link>标签和<a>标签有什么区别
react-router:如果 <Link> 处于活动状态,如何禁用它?