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

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

一、实现效果

二、代码

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.lryc.cn/news/450561.html

相关文章:

  • Git 撤销一个已经push到远端仓库的commit
  • lambda表达式底层实现
  • 鸿蒙NEXT开发-组件事件监听和状态管理(基于最新api12稳定版)
  • 《More Effective C++》的学习
  • Leetcode面试经典150题-322.零钱兑换
  • python17_len()函数
  • 车视界系统小程序的设计
  • SQLCMD命令行工具导入数据并生成对应的日志文件
  • tauri中加载本地文件图片或者下载网络文件图片后存储到本地,然后通过前端页面展示
  • QSqlDatabase在多线程中的使用
  • 【无人机设计与控制】Multi-UAV|多无人机多场景路径规划算法MATLAB
  • Visual Studio C# 编写加密火星坐标转换
  • 微服务-流量染色
  • C语言实现 操作系统 经典的进程同步问题(2)
  • 有效的字母异位词【字符串哈希】
  • 如何选择与运用工具提升工作效率的秘密指南
  • Spring系列 AOP实现过程
  • C语言 getchar 函数完全解析:掌握字符输入的关键
  • Docker安装mysql8并配置主从复制
  • 快手:数据库升级实践,实现PB级数据的高效管理|OceanBase案例
  • 基于Node.js+Express+MySQL+VUE实现的计算机毕业设计共享单车管理网站
  • 人工智能辅助的神经康复
  • KKT实际运用 -MATLAB
  • php在线相册
  • Xcode手动安装SDK模拟器
  • Docker安装consul + go使用consul + consul知识
  • JWT 漏洞 - 学习手册
  • HTML【知识改变命运】03font 字体标签
  • 集师专属知识付费小程序搭建 心理咨询小程序搭建
  • https://www.aitoolpath.com/ 一个工具数据库,目前储存了有2000+各种工具。每日更新