当前位置: 首页 > news >正文

seo建站推广泉州建站软件

seo建站推广,泉州建站软件,网页紧急升级,wordpress个人博客主题响应式react 状态管理库 14:20 react 路由(补充) 数据路由 路由hooks 路由跳转 (方法 标签/内置方法) 获取路由地址栏信息 动态路由实现(多角色权限路由) redux redux-toolkit 状态管理 antd 组件使用 1.…

react 状态管理库 14:20

  • react 路由(补充) 数据路由

  • 路由hooks

    • 路由跳转 (方法 标签/内置方法)

    • 获取路由地址栏信息

    • 动态路由实现(多角色权限路由)

  • redux redux-toolkit 状态管理

  • antd 组件使用

1.react 路由 声明式路由

v7: 数据式路由【推荐】 声明式路由

v6: 约定式路由【推荐】 配置式路由

main.js

  import { createRoot } from 'react-dom/client'import './index.css'import App from './App'import { BrowserRouter, Routes, Route } from "react-router";import Home from '@/pages/home/Home'import Coding from '@/pages/coding/Coding'import Pins from '@/pages/pins/Pins'import Course from '@/pages/course/Course'​import Following from '@/pages/following/Following'import Frontend from "@/pages/frontend/Frontend";​createRoot(document.getElementById('root')).render(<BrowserRouter><Routes><Route path="/" element={<App />}><Route   element={<Home/>}><Route index element={<Following/>}></Route><Route path="frontend" element={<Frontend/>}></Route></Route>                </Route></Routes></BrowserRouter>)

2.路由hooks

2.1 跳转页面
  • 通过组件跳转 原理 重新封装了a 标签

      <NavLink to="跳转路径" >Home</NavLink>
  • 函数式编程 跳转 hooks 跳转

  import { useNavigate } from "react-router";​​let navigate = useNavigate();​navigate(数字)  //前进几页  后退几页navigate('/goods')   //直接跟路径

2.2 获取路由地址栏信息

  import { useLocation } from 'react-router'​let location = useLocation()   //{path:'/xxx',hash:'/#/xxx'}​​

3.外卖管理系统 -项目搭建

  • 技术栈

vite

react19

react-router v7

less [新知识点:模块化css]

axios || Fetch [新知识点:fetch代替axios]

antd [新知识点]

antd charts [新:图表插件]

  • 路由配置

1.创建所有的页面

2.创建路由配置文件 src/router/index.jsx

注意 layout 页面需要反复多次使用

  import { createBrowserRouter } from "react-router";​import App from '@/App'import Login from '@/pages/login/Login'import Layout from '@/pages/layout/Layout'import Home from '@/pages/home/Home'import AccountList from '@/pages/account/List'import AccountEdit from '@/pages/account/Edit'import AccountAdd from '@/pages/account/Add'import AccountCenter from '@/pages/account/Center'import Order from "@/pages/order/Order";const router = createBrowserRouter([{path: "/",Component:App,children:[{index:true,Component:Login},{path:"home",Component:Layout,children:[{index:true,Component:Home},]},{path:'account',Component:Layout,children:[{path:'list',Component:AccountList},{path:'add',Component:AccountAdd},{path:'center',Component:AccountCenter},{path:'edit',Component:AccountEdit}]},{path:'order',Component:Layout,children:[{index:true,Component:Order}]}]},​​​])​​export default router

3.修改main.jsx 的配置

全局注入 路由配置

  ​import { createRoot } from 'react-dom/client'import './index.css'import {RouterProvider} from 'react-router'import router from '@/router'​createRoot(document.getElementById('root')).render(<RouterProvider router={router}></RouterProvider>)​

4.根页面和 一级页面需要进行占位

  • app.jsx

  import React from 'react'import { Outlet } from 'react-router'export default function App() {return (<><Outlet /></>)}​
  • layout.jsx

  import React from 'react'import { Outlet } from 'react-router'export default function Layout() {return (<><div>顶部</div><div>左侧菜单</div><div><Outlet></Outlet></div></>)}​

4.antd 使用

  • 下载安装

  pnpm install antd
  • 使用

  import React from 'react'import { Button , Form, Input } from 'antd';import './index.less'export default function Login() {​const onFinish = values => {console.log('Success:', values);};​​return (<><div className="login"><div className="form-box">​<FormonFinish={onFinish}>​<Form.Itemlabel="账号"name="account"rules={[{ required: true, message: '请输入您的账号' }]}><Input /></Form.Item>​<Form.Itemlabel="密码"name="password"rules={[{ required: true, message: '请输入密码' }]}><Input.Password /></Form.Item>​<Form.Item label={null}><Button type="primary" htmlType="submit">登录</Button></Form.Item>​​​</Form>​​</div></div></>)}​

http://www.dtcms.com/a/585174.html

相关文章:

  • HarmonyOS 诗词填空游戏开发实战教程(非AI生成 提供源代码和演示视频)
  • 【期末网页设计作业】HTML+CSS+JavaScript 蜡笔小新 动漫主题网站设计与实现(附源码)
  • 柳州建站衣联网和一起做网站。哪家强
  • 深入解析CFS虚拟运行时间:Linux公平调度的核心引擎
  • cdr做网站流程哪家公司做网站结算好
  • 专业课复习计划
  • SQL50+Hot100系列(11.8)
  • 猫狗识别数据集:34,441张高质量标注图像,深度学习二分类任务训练数据集,计算机视觉算法研发,CNN模型训练,图像识别分类,机器学习实践项目完整数据资
  • DOM NodeList 简介
  • 【数据结构】unordered 系列容器底层结构和封装
  • 昆明做网站要多少钱京津冀协同发展交通一体化规划
  • Rust编程学习 - 问号运算符会return一个Result 类型,但是如何使用main函数中使用问号运算符
  • 『 数据库 』MySQL索引深度解析:从数据结构到B+树的完整指南
  • Spring JDBC源码解析:模板方法模式的优雅实践
  • 19-Node.js 操作 Redis 实战指南:ioredis 客户端全解析与异步场景落地
  • linux服务-iptables 原理及示例详解
  • Firebase 架构原理与实战入门:从零搭建你的第一个云端应用
  • 精品在线试题库系统|基于SpringBoot和Vue的精品在线试题库系统(源码+数据库+文档)
  • AI时代职场反脆弱性:杠铃策略平衡稳定工作与高风险创新
  • 网站搭建的步骤wordpress 添加评论
  • SLAM中的非线性优-3D图优化之轴角在Opencv-PNP中的应用(一)
  • Rust 练习册 :Poker与扑克牌游戏
  • 【python】基础案例分析
  • LeetCode(python)——15.三数之和
  • Java基础——集合进阶用到的数据结构知识点1
  • 无线交换机(AC)核心技术详解:构建集中式Wi-Fi网络的基石
  • DNS的正向、反向解析的服务配置知识点及实验
  • 庖丁解牛:深度剖析 Ascend C 算子开发流程与核心概念
  • 《Learn Python Programming(4th)》读后感
  • 网站开发毕业生报告网页设计与制作项目教程陈义文