随笔分类 -  Router

摘要:useNavigate() may be used only in the context of a <Router> component. //useNavigate()只能在<Router>组件的上下文中使用。 解决办法,将使用useNavigate或useHistory的组件和方法封装成一个新 阅读全文
posted @ 2022-06-14 09:22 SimoonJia 阅读(2276) 评论(0) 推荐(0) 编辑
摘要:import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; 使用 <Routers>包裹 来替代之前版本的<switch>且Route必须被包裹在Routes中 <Route path="/pd3" compo 阅读全文
posted @ 2022-06-14 09:01 SimoonJia 阅读(519) 评论(0) 推荐(0) 编辑
摘要:前进后退不可使用 (独立页面相似意思) 普通式重定向 1.设置route <Route path="/home/" component={Home}/> 2.书写组件 import React, { Component } from 'react' class Home extends Compon 阅读全文
posted @ 2022-06-13 03:37 SimoonJia 阅读(56) 评论(0) 推荐(0) 编辑
摘要:1.设置规则 <Route path="/list/:id" component={List}/> {/* 1.规则 */} 2.传值(或在地址栏自己设置) <li><Link to="/list/123">列表</Link></li> 3.接收值 import React, { Component 阅读全文
posted @ 2022-06-13 03:12 SimoonJia 阅读(85) 评论(0) 推荐(0) 编辑
摘要:<Route path="/" exact component={Index}/> <Route path="/list/" component={List}/> /: 加exact 地址栏 /***匹配不到/对应的component 不加exact /***能匹配到 /list/: 加exact 阅读全文
posted @ 2022-06-13 02:19 SimoonJia 阅读(85) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示