国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

react-router4 嵌套路由的使用方法

2024-05-06 15:13:56
字體:
來源:轉載
供稿:網友

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

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 安图县| 通榆县| 石家庄市| 北安市| 融水| 徐汇区| 周口市| 安多县| 南城县| 晋宁县| 阜平县| 德州市| 宁安市| 丽江市| 汕头市| 哈密市| 景德镇市| 松滋市| 奉化市| 建宁县| 六盘水市| 定西市| 日照市| 秦安县| 禹城市| 通江县| 枣强县| 政和县| 德兴市| 禹州市| 屯留县| 仙桃市| 南乐县| 涿鹿县| 陕西省| 新民市| 冷水江市| 田东县| 礼泉县| 攀枝花市| 安乡县|