真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

如何實現(xiàn)react-router-dom嵌套路由

小編這次要給大家分享的是如何實現(xiàn)react-router-dom嵌套路由,文章內(nèi)容豐富,感興趣的小伙伴可以來了解一下,希望大家閱讀完這篇文章之后能夠有所收獲。

網(wǎng)站建設(shè)公司,為您提供網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)頁設(shè)計及定制網(wǎng)站建設(shè)服務(wù),專注于企業(yè)網(wǎng)站制作,高端網(wǎng)頁制作,對成都辦公窗簾等多個行業(yè)擁有豐富的網(wǎng)站建設(shè)經(jīng)驗的網(wǎng)站建設(shè)公司。專業(yè)網(wǎng)站設(shè)計,網(wǎng)站優(yōu)化推廣哪家好,專業(yè)seo優(yōu)化優(yōu)化,H5建站,響應(yīng)式網(wǎng)站。

入口文件index.js:

import React from "react"
import ReactDOM from "react-dom"
import App from "./App.jsx"
import "babel-polyfill"
const root = document.getElementById("app")
if (root !== null) {
 ReactDOM.render(, document.getElementById("app"))
}

各個文件的詳細位置:

如何實現(xiàn)react-router-dom嵌套路由

主要目錄App.jsx:

import React, { Fragment, Component } from "react"
import {
 BrowserRouter as Router,
 Switch,
 Route,
 NavLink,
 Redirect,
 Link,
 withRouter,
} from "react-router-dom"
// 開始引入各種自定義的組件
import Index from "./pages/platform/index"
//404頁面
import ErrorPage from "./pages/ErrorPage"
import Login from "./pages/login/index"
import routes from "./routes/index"


class BaseLayout extends Component {
 constructor(props) {
  super(props)
  }
  
  render(){
    return(
    
      
    {routes.map((val,index))=>{ return(
  • {val.authName}
  • ) }
{routes.map((route, key) => { if (route.exact) { return ( { return ( ) }} > {/* */} ) } else { return ( { return ( ) }} > {/* */} ) } })}
) } } class App extends React.Component { constructor(props) { super(props) } render() { return ( ) } } export default App

放路由route.js:

import Index from "../pages/platform/index"
import UserAdd from "../pages/component/User/UserAdd"
import UserList from "../pages/component/User/UserList"

const routes = [
 {
  path: "/index",
  authName: "首頁",
  component: Index,
  exact: true,
 },
 {
  path: "/user",
  authName: "用戶1",
  component: UserList,
 },
 {
  authName: "用戶2",
  path: "/userAdd",
  component: UserAdd,
 },
]
export default routes

其他頁面login.jsx:

import React, { Component } from "react"

export default class Login extends Component {
 render() {
  return 
Login
} }

其他頁面index.jsx:

import React, { Component } from "react"

export default class Index extends Component {
 render() {
  return 
Index
} }

其他頁面UserAdd.jsx:

import React, { Component } from "react"

export default class UserAdd extends Component {
 render() {
  return 
UserAdd
} }

其他頁面UserList.jsx:

import React, { Component } from "react"

export default class UserList extends Component {
 render() {
  return 
UserList
} }

看完這篇關(guān)于如何實現(xiàn)react-router-dom嵌套路由的文章,如果覺得文章內(nèi)容寫得不錯的話,可以把它分享出去給更多人看到。


當(dāng)前名稱:如何實現(xiàn)react-router-dom嵌套路由
瀏覽地址:http://weahome.cn/article/gcjogs.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部