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

哪些网站可以接任务做兼职济南建设招标网

哪些网站可以接任务做兼职,济南建设招标网,网站建设要学哪种计算机语言,h5制作价格我们先上代码,代码里面都有注释,我是单独写了一个组件,方便使用,在其他页面引入就行了 还使用了官方的Breadcrumb组件 import React, { useEffect, useState } from react; import { Breadcrumb, Button } from antd; import { …

我们先上代码,代码里面都有注释,我是单独写了一个组件,方便使用,在其他页面引入就行了

还使用了官方的Breadcrumb组件

import React, { useEffect, useState } from 'react';
import { Breadcrumb, Button } from 'antd';
import { useLocation, NavLink, useNavigate } from 'react-router-dom';// 定义面包屑项的类型
interface LocaItem {path: string;title: string;
}interface CustomBreadcrumbProps {title: string; // 当前页面的标题,动态传递
}const CustomBreadcrumb: React.FC<CustomBreadcrumbProps> = ({ title }) => {const navigate = useNavigate();const location = useLocation();const [loca, setLoca] = useState<LocaItem[]>([]);useEffect(() => {// 获取存储的面包屑数据const storedLoca = JSON.parse(sessionStorage.getItem('loca') || '[]');// 创建新面包屑项const newObject: LocaItem = {path: location.pathname,title: title, // 使用传入的 title 作为当前页面的标题};// 判断 loca 中是否有相同的 titleconst isExist = storedLoca.some((item: LocaItem) => item.title === newObject.title);// 如果不存在相同的 title,就 push 新对象if (!isExist) {storedLoca.push(newObject);sessionStorage.setItem('loca', JSON.stringify(storedLoca)); // 存储新的面包屑数据}setLoca(storedLoca); // 更新组件状态}, [location.pathname, title]); // 每次路径或标题变化时,更新面包屑// 删除面包屑项const handleRemove = (path: string) => {console.log(location.pathname);console.log(path);// 检查路径是否相同if (location.pathname === path) {const pathlink = JSON.parse(sessionStorage.getItem('loca') || '[]');const pathlinkLength = pathlink.length - 1;if (path === pathlink[pathlinkLength].path) {const newPath = String(pathlink[pathlinkLength - 1]?.path);// 延迟跳转,确保状态更新后执行setTimeout(() => {navigate(newPath || '/'); // 如果路径为空,跳转到默认页面}, 0);} else {const newPath = String(pathlink[pathlinkLength - 2]?.path);// 延迟跳转,确保状态更新后执行setTimeout(() => {navigate(newPath || '/'); // 如果路径为空,跳转到默认页面}, 0);}}// 更新面包屑数据const updatedLoca = loca.filter((item) => item.path !== path);sessionStorage.setItem('loca', JSON.stringify(updatedLoca)); // 更新 sessionStoragesetLoca(updatedLoca); // 更新状态};// 渲染面包屑项const breadcrumbItems = loca.map((item: LocaItem) => ({title: (<span style={{ display: 'flex', alignItems: 'center', marginLeft: '10px' }}><NavLinkto={item.path}style={({ isActive }) => ({fontWeight: isActive ? 'bold' : 'normal', // 高亮显示color: isActive ? '#1890FF' : 'normal', // 当前项文字颜色backgroundColor: isActive ? '#e6f7ff' : 'normal', // 当前项背景颜色borderBottom: isActive ? '1px solid #1890FF' : 'normal',borderRadius: '0',height: '30px',lineHeight: '30px',padding: '0 10px 0 10px',})}>{item.title}</NavLink>{/* 关闭按钮 */}<ButtononClick={() => handleRemove(item.path)} // 点击删除当前面包屑项disabled={item.title === "首页"} // 禁用“首页”按钮type="link"icon={<span style={{ fontSize: '16px' }}>×</span>}style={{padding: 0,fontSize: '16px',display: item.title === "首页" ? 'none' : 'block',width: '20px',margin: item.title === "首页" ? '0 5px 0 0' : '0',}}/></span>),}));return (<Breadcrumbstyle={{margin: '16px 0',height: '30px',}}items={breadcrumbItems} // 使用动态生成的面包屑项separator="" // 去掉默认的斜杠分隔符itemRender={(route) => {return (<span style={{ marginRight: '10px',whiteSpace:'nowrap' }}>{route.title}</span> // 给每个面包屑项加间距);}}/>);
};export default CustomBreadcrumb;

然后在其他页面引入

import Breadcrumbs from '../../../src/components/Breadcrumb/Breadcrumb';

使用:

title是面包屑的名称,你也可以获取当前路由的title,写个动态的

<Breadcrumbs title="需求管理" />

效果:

http://www.yayakq.cn/news/914910/

相关文章:

  • 做企业网站的人才公司要招个做网站的人
  • 做360全景有什么网站电商平台运营公司
  • 团购网站建设北京网络推广有哪些公司
  • 庆阳网站设计师招聘wap浏览器网页版
  • 外贸网站建设内容包括哪些wordpress主题视频
  • 学会网站制作要多久网站建设什么打王思聪
  • 吉安网站设计怎样让自己做的网站被百度收录
  • 营销网站建设818gx怎么样可以做自己的网站
  • 济南企业网站开发百度云虚拟主机上传wordpress
  • 垣宝建设工程集团网站wordpress文章不显示图片
  • 好看的wordpress模版wordpress优化加速缓存中国
  • 网站备案号添加网站投放广告多少钱
  • wordpress 网站播放器插件自己怎么设计公司标志
  • 网站博客程序阿里云网站建设模板
  • 网站域名设计推荐企业建设营销型网站的目的有
  • 新手如何入侵一个网站wamp搭建wordpress
  • 旅行网站开发背景漳州网站开发找出博大科技
  • 人才交流网站建设与设计网页设计下载方式
  • 专题探索网站开发教学模式的结构网站开发工程师面试试题
  • 本地建站软件有哪些住房和城乡建设部执业资格注册中心网站
  • 传媒公司网站源码php网页后端开发需要学什么
  • 360网站提交入口地址中铁建设集团华东分公司网站
  • 网站建设的安全威胁一级域名建站网站建设行吗
  • 公司建设网站需求分析报告wordpress 织梦 米拓
  • 网站建设一般用什么编程专业做调查的网站
  • 运动服饰网站建设需求分析北京网站建设学校
  • 网站开发相关职业岗位微信导购网站怎么做视频教学
  • 做壁画的网站互联网公司排名2024中国
  • 12306网站为什么做不好网站平台延展性
  • 专业手机网站设计网站制作公司十强