react+antdMobie实现消息通知页面样式

devtools/2024/10/4 12:28:50/

一、实现效果

二、代码

import React, { useEffect, useState } from 'react';
import style from './style/index.less';
import { CapsuleTabs, Ellipsis, Empty, SearchBar, Tag } from 'antd-mobile';
//消息通知页面
export default function Notification(props) {const [options, setOptions] = useState([{label: '最近',value: 'zj',checked: true,},{label: '评审通知',value: 'pstz',checked: false,},{label: '政策制度',value: 'zczd',checked: false,},{label: '知识库',value: 'zsk',checked: false,},{label: '常见问题',value: 'cjwt',checked: false,},]);const [list, setList] = useState([{title: '通知公告名称1111',ywlx: 'pstz',content: '公告简介:公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介介公告简介公告简介公告简介公告简介',},{title: '通知公告名称1111',ywlx: 'zczd',content: '公告简介:公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介介公告简介公告简介公告简介公告简介',},{title: '通知公告名称1111',ywlx: 'zsk',content: '公告简介:公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介介公告简介公告简介公告简介公告简介',},{title: '通知公告名称1111',ywlx: 'cjwt',content: '公告简介:公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介介公告简介公告简介公告简介公告简介',},{title: '通知公告名称1111',ywlx: 'pstz',content: '公告简介:公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介公告简介介公告简介公告简介公告简介公告简介简介公告简介公告简简介公告简介公告简简介公告简介公告简',},]);const [checkedList, setCheckedList] = useState([]);useEffect(() => {setCheckedList(list);}, [props]);//切换条件const toggle = (item, index) => {const element = document.getElementById('option');if (element) {element.scroll({top: 0,left: 50 * Number(index), // 计算目标位置behavior: 'smooth',});}const newoptions = options.map((res) => {return {...res,checked: res == item,};});setOptions(newoptions);toggleList(item);};const toggleList = (item) => {if (item.value == 'zj') {setCheckedList(list);} else {const newList = list.filter((res) => {return res.ywlx == item.value;});setCheckedList(newList);}};return (<><div className={style.container}><div className={style.top}><SearchBarplaceholder="输入事项名称或者关键字"className={style.search}style={{'--background': 'rgba(255, 255, 255, 0.35)','--height': '32px','--placeholder-color': 'rgba(255, 255, 255, 0.65)',}}/></div><div className={style.option} id="option">{options.map((item, index) => {return (<divkey={index}className={`${item.checked ? style.checked : style.block}`}onClick={() => {toggle(item, index);}}>{item.label}</div>);})}</div><div className={style.content}>{checkedList.map((item, index) => {return (<div key={index} className={style.card}><div style={{ display: 'flex', alignItems: 'center', borderBottom: '1px solid #979797' }}>{item.ywlx == 'pstz' && <Tag color="#2db7f5">评审通知</Tag>}{item.ywlx == 'zczd' && <Tag color="#1ac4c4">政策制度</Tag>}{item.ywlx == 'zsk' && <Tag color="#87d068">知识库</Tag>}{item.ywlx == 'cjwt' && <Tag color="#cf1322">常见问题</Tag>}<span className={style.title}>{item.title}</span></div><div className={style.desc}><Ellipsis direction="end" content={item.content} rows={2} /></div></div>);})}{checkedList.length == 0 && <Empty style={{ padding: '64px 0' }} imageStyle={{ width: 128 }} description="暂无数据" />}</div></div></>);
}

三、css样式

::-webkit-scrollbar {width: 0px;
}.container {height: 100vh;width: 100%;overflow-y: auto;overflow-x: hidden;position: fixed;font-size: 14px;.top {background-color: #BF120D;height: 90px;display: flex;align-items: center;.search {width: 95%;margin: auto;padding-top: 20px;}}.option {display: flex;align-items: center;overflow-x: auto;min-height: 70px;.block {color: #979797;font-weight: 400;border-radius: 6px;border: 1px solid #979797;margin: 0px 10px;padding: 5px 10px;min-width: 100px;text-align: center;}.checked {color: #fff;background-color: #BF120D;font-weight: 400;border-radius: 6px;border: 1px solid #BF120D;margin: 0px 10px;padding: 5px 10px;min-width: 100px;text-align: center;position: relative;}.checked::after {content: '';position: absolute;left: 50%;bottom: -10px;/* 小箭头的位置调整 */width: 0;height: 0;border-left: 10px solid transparent;border-right: 10px solid transparent;border-top: 10px solid #BF120D;/* 小箭头的颜色 */transform: translateX(-50%);}}.content {position: relative;margin-bottom: 10%;.card {padding: 10px;border-radius: 8px;margin: 10px auto;width: 96%;background-color: #fff;display: flex;align-items: center;.title {font-weight: 600;display: flex;align-items: center;line-height: 0.3rem;font-size: 0.18rem;}.sj {text-align: end;color: #999;}}}// 消息明细.detail_content {padding: 10px;background-color: #fff;.title {font-size: 0.16rem;font-weight: 700;line-height: 0.4rem;text-align: center;}.qt {display: flex;align-items: center;justify-content: space-between;color: #999;line-height: 0.4rem;}}}

 


http://www.ppmy.cn/devtools/121254.html

相关文章

排序算法之——归并排序,计数排序

文章目录 前言一、归并排序1. 归并排序的思想2. 归并排序时间复杂度及空间复杂度3. 归并排序代码实现1&#xff09;递归版本2&#xff09;非递归版本 二、计数排序1. 计数排序的思想2. 计数排序的时间复杂度及空间复杂度3. 计数排序代码实现 总结&#xff08;排序算法稳定性&am…

【Qt Quick】基础语法:变量类型

在本节中&#xff0c;我们将讨论 QML 中的变量类型。与 C 相似&#xff0c;QML 也有多种变量类型&#xff0c;但在 QML 中&#xff0c;主要分为值类型和对象类型。由于 QML 没有指针的概念&#xff0c;因此在值类型和对象类型的传递中有一些不同点。 值类型和对象类型 值类型…

《深度学习》OpenCV 图像拼接 拼接原理、参数解析、案例实现

目录 一、图像拼接 1、直接看案例 图1与图2展示&#xff1a; 合并完结果&#xff1a; 2、什么是图像拼接 3、图像拼接步骤 1&#xff09;加载图像 2&#xff09;特征点检测与描述 3&#xff09;特征点匹配 4&#xff09;图像配准 5&#xff09;图像变换和拼接 6&am…

HBase 性能优化 详解

HBase 是基于 Hadoop HDFS 之上的分布式 NoSQL 数据库&#xff0c;具有高伸缩性和强大的读写能力。然而&#xff0c;由于其分布式架构和复杂的数据存储模式&#xff0c;在高并发、大规模数据场景下&#xff0c;HBase 性能优化至关重要。从底层原理和源代码层面理解 HBase 的特性…

dockerhub 镜像拉取超时的解决方法

在几个月前&#xff0c;因为一些原因&#xff0c;导致 dockerhub 官网上面的镜像拉取超时&#xff0c;目前可以通过修改仓库地址&#xff0c;通过 daocloud 拉取 public-image-mirror 方式一 源仓库替换仓库cr.l5d.iol5d.m.daocloud.iodocker.elastic.coelastic.m.daocloud.io…

Redis篇(数据类型)

目录 讲解一&#xff1a;简介 讲解二&#xff1a;常用 一、String类型 1. 简介 2. 常见命令 3. Key结构 4. 操作String 5. 实例 二、Hash类型 1. 简介 2. 常见命令 3. 3操作hash 4. 实例 三、List类型 1. 简介 2. 特征 3. 应用场景 4. 常见命令 5. 操作list …

1-仙灵之谜(区块链游戏详情介绍)

1-仙灵之谜&#xff08;区块链游戏详情介绍&#xff09; 前言&#xff08;该游戏仅供娱乐&#xff09;正文 前言&#xff08;该游戏仅供娱乐&#xff09; 依稀记得本科那会儿参加了一个区块链实验室&#xff0c;那时每周末大家都会爬山或者抽出一下午讨论区块链以及未来&#x…

用责任链模式改造 if else

我的上一篇文章&#xff0c;因为if else 多了&#xff0c;捣鼓很久&#xff0c;今天用责任链模式改造一下。 代码写着写着&#xff0c;if else if 逻辑忘记了&#xff0c;哎。。。-CSDN博客 责任链模式&#xff08;Chain of Responsibility Pattern&#xff09; 1. 什么是责任…