赞
踩
import React, { Component } from "react"; import Div1 from "./components/div1" import Div2 from "./components/div2" import Page1 from "./pages/page1"; import Page2 from "./pages/page2"; import { Link, BrowserRouter, Route, NavLink } from "react-router-dom"; export default class App extends Component { render() { return ( <div> <BrowserRouter> <NavLink activeClassName="acc" to="/a"> a </NavLink> <NavLink activeClassName="acc" to="/b"> b </NavLink> <Route path="/a" component={Page1} /> <Route path="/b" component={Page2} /> <Route path="/b" component={Page1} /> </BrowserRouter> <Div1>123456789/Div1</Div1> </div> ); } }
import React, { Component } from "react"; import Div1 from "./components/div1"; import Div2 from "./components/div2"; import Page1 from "./pages/page1"; import Page2 from "./pages/page2"; import { Link, BrowserRouter, Route, NavLink, Switch } from "react-router-dom"; export default class App extends Component { render() { return ( <div> <BrowserRouter> <NavLink activeClassName="acc" to="/a"> a </NavLink> <NavLink activeClassName="acc" to="/b"> b </NavLink> <Switch> <Route path="/a" component={Page1} /> <Route path="/b" component={Page2} /> <Route path="/b" component={Page1} /> </Switch> </BrowserRouter> <Div1>123456789/Div1</Div1> </div> ); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。