叶子小小的,碧绿碧绿的,花儿小小的,好可爱。紫红色的玫瑰花在风中翩翩起舞,玫瑰花树枝上还有调皮又可爱的小刺,你可要当心哦!你看,那个大仙人球旁围着8个小仙人球,好像一家人聚在一起,多欢快呀!
react我自己还在摸索学习中,今天正好学习一下react-router4 嵌套路由的使用方法,顺便留着笔记
先直接贴代码
import React from 'react'; import ReactDOM from 'react-dom'; import { HashRouter as Router, Route, Switch} from 'react-router-dom'; import createBrowserHistory from 'history/createBrowserHistory'; import UserAddPage from './pages/UserAdd/index'; import HomePage from './pages/Home/index'; import HomeLayout from './components/HomeLayout/index'; const hashHistory = createBrowserHistory(); const NoMatch = ({ location }) => ( <div> <h3>无法匹配 <code>{location.pathname}</code></h3> </div> ) ReactDOM.render(( <Router history={hashHistory}> <div> <HomeLayout>//总会加载这个组件,并且下面 swicth 里面的组件会在它里面 render <Switch> <Route path="/" exact component={HomePage}/> <Route path="/user/add" component={UserAddPage}/> <Route component={NoMatch}/> </Switch> </HomeLayout> </div> </Router> ), document.getElementById('root'));
参考文章:https://stackoverflow.com/questions/42095600/nested-routes-in-v4
以上就是react-router4 嵌套路由的使用方法。唯有艺术和学问从来不辜负人;花多少劳力,用多少苦功,拿出多少忠诚和热情,就得到多少收获与进步。更多关于react-router4 嵌套路由的使用方法请关注haodaima.com其它相关文章!