react-router4 嵌套路由的使用方法
react我自己还在摸索学习中,今天正好学习一下react-router4嵌套路由的使用方法,顺便留着笔记
先直接贴代码
importReactfrom'react';
importReactDOMfrom'react-dom';
import{HashRouterasRouter,Route,Switch}from'react-router-dom';
importcreateBrowserHistoryfrom'history/createBrowserHistory';
importUserAddPagefrom'./pages/UserAdd/index';
importHomePagefrom'./pages/Home/index';
importHomeLayoutfrom'./components/HomeLayout/index';
consthashHistory=createBrowserHistory();
constNoMatch=({location})=>(
无法匹配{location.pathname}
)
ReactDOM.render((
//总会加载这个组件,并且下面swicth里面的组件会在它里面render
),document.getElementById('root'));
参考文章:https://stackoverflow.com/questions/42095600/nested-routes-in-v4
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
热门推荐
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短