-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
30 lines (28 loc) · 1.07 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import "./style.css";
import { HashRouter, Link } from "./react-router-dom"
import { Route, Switch, Redirect } from "./react-router"
export default function App() {
return (
<HashRouter>
<div>
<Link to="/home">首页</Link>
<Link to="/home/1">首页1</Link>
<Link to="/about">关于</Link>
<Link to="/list">列表</Link>
</div>
<Switch>
<Route path="/home" component={Home}></Route>
<Route path="/home/1" component={Home1}></Route>
<Route path="/about" component={About}></Route>
<Route path="/list" component={List}></Route>
<Route path="/notFound" component={NotFound} />
<Route path="/a" render={() => <Redirect to="/notFound" />} />
</Switch>
</HashRouter>
);
}
const Home = () => <div>首页</div>;
const Home1 = () => <div>首页1</div>;
const About = () => <div>关于</div>;
const List = () => <div>列表</div>;
const NotFound = () => <div>404</div>;