react router dom 巢狀路由

2022-02-26 18:33:51 字數 1533 閱讀 1868

入口檔案index.js:

import react from "react"

import reactdom from "react-dom"

import "babel-polyfill"

if (root !== null)

各個檔案的詳細位置:

import react,  from "react"

import 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

render()}

>

)} else }

>)}

})})

}} constructor(props)

render()

}

放路由route.js:

import index from "../pages/platform/index"

import useradd from "../pages/component/user/useradd"

import userlist from "../pages/component/user/userlist"

const routes = [

, ,

,]export default routes

其他頁面login.jsx:

import react,  from "react"

export default class login extends component

}

其他頁面index.jsx:

import react,  from "react"

export default class index extends component

}

其他頁面useradd.jsx:

import react,  from "react"

export default class useradd extends component

}

其他頁面userlist.jsx:

import react,  from "react"

export default class userlist extends component

}

時間緊急,先寫下這個做筆記

react router dom巢狀路由

路由配置 import react from react import reactdom from react dom import utils common.scss 在入口檔案中進行路由的配置其中browserrouter是非hash路由的模式url後面不會帶有 route是對應每個路由元件主要...

react router dom路由模組化

1 先看一下未模組化的路由配置,有哪些地方是可以提出去的 import react from react import css index.css import from react router dom 這一塊是可以單獨提出去的 start import entrypage from compon...

react router dom路由的基本使用

在react中啟用路由模組,首先要裝包 npm i react router dom s,裝完之後在根元件中匯入 import from react router dom import react from react import from react router dom import home...