React + 项目(从基础到实战) -- 第六期

引入ant design ui

ui 组件库介绍

组件总览 - Ant Design (antgroup.com)
安装 - Material-UI (mui.com)
Tailwind UI - Official Tailwind CSS Components & Templates

引入antd

Ant Design of React - Ant Design

常用组件

// 引入antd 美化import { Layout } from 'antd';const { Header, Footer, Content } = Layout;//引入组件import {Button,Space,Divider} from 'antd';//引入图标import {PlusOutlined ,BarsOutlined,StarOutlined,DeleteOutlined,} from '@ant-design/icons';//引入组件import {Space,Typography} from 'antd';//引入图标import { FormOutlined } from '@ant-design/icons';import { HOME_PATH } from '../router';const { Title } = Typography;

定义常用的路由常量

export const HOME_PATH='/'export const LOGIN_PATH='/login'export const REGISTER_PATH='/register'export const MANAGE_PATH='/manage/list'

我的问卷: 列表卡片

问卷卡片 : 气泡弹出框使用

 <Popconfirmtitle="复制问卷?"okText="确定"cancelText="取消"onConfirm={duplicate}><Button type="text" icon={<CopyOutlined/>} size="small">复制</Button></Popconfirm>

问卷卡片:confirm弹出框

const {confirm} = Modal;confirm({title: '确定删除吗?',icon: <ExclamationCircleOutlined />,content: '删除后问卷将无法恢复',okText: '确定',cancelText: '取消',onOk() {message.success("删除成功")},onCancel() {message.error("取消删除")},})

问卷卡片

import React , { FC} from "react";import styles from "./QuestionCard.module.scss";import { Link, useNavigate } from "react-router-dom";//引入组件import{Divider, Space, Tag,Button, message, Popconfirm ,Modal} from "antd";//引入icon图标import { EditOutlined, StarOutlined ,BarsOutlined, CopyOutlined, DeleteOutlined ,ExclamationCircleOutlined} from "@ant-design/icons";const {confirm} = Modal;//组件传值//定义属性type PropsType={id:string,title:string,isPublished:boolean,isStar:boolean,answerCount:numbercreateAt:string,}const QuestionCard:FC<PropsType> = (props:PropsType) => {const {id,title,isPublished,isStar,answerCount,createAt}=propsconst nav=useNavigate();function duplicate(){message.success("执行复制")}function del(){confirm({title: '确定删除吗?',icon: <ExclamationCircleOutlined />,content: '删除后问卷将无法恢复',okText: '确定',cancelText: '取消',onOk() {message.success("删除成功")},onCancel() {message.error("取消删除")},})}return (<><div className={styles.container} ><div className={styles.title}><div className={styles.left}><Link to={isPublished ? `/question/stat/${id}` : `/question/edit/${id}`}><Space>{isStar && <StarOutlined style={{color:'red'}}/>}{title}</Space></Link></div><div className={styles.right}><Space>{isPublished ? <Tag color="processing">已发布</Tag>: <Tag>未发布</Tag>}<span> 答卷数量: {answerCount}  </span><span>{createAt}</span></Space></div></div><Divider style={{margin:'10px 0'}}></Divider><div className={styles.bottom}><div className={styles.left}><Space><Button icon={<EditOutlined/>} type="text" size='small' onClick={()=>nav(`/question/edit/${id}`)} >编辑问卷</Button><Button icon={<BarsOutlined/>} type="text" size='small' onClick={()=>nav(`/question/stat/${id}`)}>问卷统计</Button></Space></div><div className={styles.right}><Space><Button type="text" icon={<StarOutlined/>} size="small">{isStar ? "取消标星" : "标星问卷"}</Button><Popconfirmtitle="复制问卷?"okText="确定"cancelText="取消"onConfirm={duplicate}><Button type="text" icon={<CopyOutlined/>} size="small">复制</Button></Popconfirm><Button type="text" icon={<DeleteOutlined/>} size="small" onClick={del}>删除</Button></Space></div></div></div></>)}export default QuestionCard;

星标问卷:列表卡片+分页

和上面差不多

回收站 : 表格


/表格列const tableColums=[{title:"标题",dataIndex:"title",// key:"title"//循环的key,他会默认取dataIndex的值},{title:"是否发布",dataIndex:"isPublished",render:(isPublished:boolean)=>{return isPublished ?  <Tag color="processing">已发布</Tag> : <Tag>未发布</Tag>}},{title:"答卷",dataIndex:"answerCount"},{title:"创建时间",dataIndex:"createAt"}]//问卷列表数据模拟const rawQuestionList=[{//_id:"1"  mondob数据库id:'1',title:"问卷1",isPublished:false,isStar:true,answerCount:100,createAt:"4月5日 12:23"},{id:'2',title:"问卷2",isPublished:true,isStar:false,answerCount:100,createAt:"4月5日 12:23"},{id:'3',title:"问卷3",isPublished:true,isStar:true,answerCount:100,createAt:"4月5日 12:23"},{id:'4',title:"问卷4",isPublished:false,isStar:false,answerCount:100,createAt:"4月5日 12:23"}]<TabledataSource={questionList}columns={tableColums}pagination={false}rowKey={(record)=>record.id}/>

添加恢复删除功能

 //将jsx片段提取成为变量//表格项提取出来const TableElem = <><div style={{marginBottom:"16px"}}><Space><Button type="primary" disabled={selectedIds.length==0}>恢复</Button><Button danger disabled={selectedIds.length==0} onClick={del}>彻底删除</Button></Space></div><TabledataSource={questionList}columns={tableColums}pagination={false}rowKey={(record)=>record.id}rowSelection={{type:"checkbox",onChange:(selectedRowKeys)=>{setSelectedIds(selectedRowKeys as string[])}}}/></>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/816279.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

详解拷贝构造

拷贝构造的功能 写法&#xff1a; 拷贝构造函数的参数为什么是引用类型 系统自动生成的拷贝构造函数 拷贝构造的深拷贝与浅拷贝 概念 浅拷贝&#xff1a; 深拷贝 小结 拷贝构造的功能 拷贝构造函数可以把曾经实例化好的对象的数据拷贝给新创建的数据 &#xff0c;可见…

ASP.NET基于BS的计算机等级考试系统的设计与实现

摘 要 随着计算机技术的发展及计算机的日益普及&#xff0c;基于B/S结构的考试系统与无纸化办公一样已成为大势所趋。论文详细论述了一个基于B/S结构的计算机等级考试系统的设计过程。软件采用ASP.NET 2005作开发平台&#xff0c;C#作编程语言&#xff0c;SQL Server 2005作…

网络安全从入门到精通(特别篇I):Windows安全事件应急响应之Windows应急响应基础必备技能

Windows应急 询问攻击情况范围 事件发生时的状况或安全设备告警等,能帮助应急处置人员快速分析确定事件类型,方便前期准备。 通用排查思路 入侵肯定会留下痕迹,另外重点强调的是不要一上来就各种查查查,问清楚谁在什么时间发现的主机异常情况,异常的现象是什么,受害用…

【DNS】

文章目录 DNS域名解析系统&#xff08;Domain Name System&#xff09;DNS系统需要解决的问题DNS域名解析系统&#xff08;Domain Name System&#xff09;问题1&#xff1a;DNS名字空间(The DNS Name Space&#xff09;DNS名字空间(The DNS Name Space)DNS名字空间(The DNS Na…

边缘计算【智能+安全检测】系列教程--使用OpenCV+GStreamer实现真正的硬解码,完全消除马赛克

通过现有博客的GST_URL = "rtspsrc location=rtsp://admin:abcd1234@192.168.1.64:554/h264/ch01/main/av_stream latency=150 ! rtph264depay ! avdec_h264 ! videorate ! videoconvert ! appsink sync=false" GStreamer的解码方式解码,大多情况应该存在上图马赛克…

解决jenkins运行sh报process apparently never started in XXX

个人记录 问题 process apparently never started in /var/jenkins_home/workspace/ks-springboot_mastertmp/durable-bbfe5f99(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICStrue might make the problem cl…

架构师系列-搜索引擎ElasticSearch(八)- 集群管理故障恢复

故障转移 集群的master节点会监控集群中的节点状态&#xff0c;如果发现有节点宕机&#xff0c;会立即将宕机节点的分片数据迁移到其它节点&#xff0c;确保数据安全&#xff0c;这个叫做故障转移。 下图中node1是主节点&#xff0c;其他两个节点是从节点 节点故障 此时node1…

卷积神经网络(LeNet5实现对Fashion_MNIST分类

参考6.6. 卷积神经网络&#xff08;LeNet&#xff09; — 动手学深度学习 2.0.0 documentation (d2l.ai) ps&#xff1a;在这里预备使用pythorch 1.对 LeNet 的初步认识 总的来看&#xff0c;LeNet主要分为两个部分&#xff1a; 卷积编码器&#xff1a;由两个卷积层组成; …

【蓝桥杯】(完全日期)

完全日期 #include <iostream> using namespace std; int main() {int ans0;//2001 1 1 //2021 12 31int monthday[13]{0,31,28,31,30,31,30,31,31,30,31,30,31};for(int year2001;year<2021;year){monthday[2]28;if((year%40&&year%100!0)||year%4000)month…

OLTP 与 OLAP 系统说明对比和大数据经典架构 Lambda 和 Kappa 说明对比——解读大数据架构(五)

文章目录 前言OLTP 和 OLAPSMP 和 MPPlambda 架构Kappa 架构 前言 本文我们将研究不同类型的大数据架构设计&#xff0c;将讨论 OLTP 和 OLAP 的系统设计&#xff0c;以及有效处理数据的策略包括 SMP 和 MPP 等概念。然后我们将了解经典的 Lambda 架构和 Kappa 架构。 OLTP …

嵌AR/VR开发教程和案例

一、AR/VR概述 增强现实&#xff08;Augmented Reality&#xff0c;简称AR&#xff09;和虚拟现实&#xff08;Virtual Reality&#xff0c;简称VR&#xff09;是近年来备受关注的技术领域。AR是在现实世界的基础上&#xff0c;通过计算机技术将虚拟信息叠加到现实世界中&…

无线通信:多输入多输出(MIMO)

什么是MIMO MIMO&#xff08;Multi Input Multi Output&#xff09;即多输入多输出&#xff0c;通过采用空间复用技术&#xff0c;在几条链路&#xff08;可以理解为几个天线&#xff09;中传输不同的数据码流&#xff0c;成倍地提高数据吞吐量&#xff08;速率&#xff09;。…

振兴国腾GM8775C MIPIDSI桥接到双 PORT LVDS

GM8775C描述&#xff1a; GM8775C 型 DSI 转双通道 LVDS 发送器产品主要实现将 MIPI DSI 转单 / 双通道 LVDS 功能&#xff0c;MIPI 支持 1/2/3/4 通道可选&#xff0c;每通道最高支持 1Gbps 速率&#xff0c;最大支持 4Gbps 速率。LVDS 时钟频率高达 154MHz &a…

实现文章内容过多时的展开收起效果

通过计算文章内容的高度来确定是否需要显示展开按钮&#xff0c;然后根据用户的点击来展开或收起文章内容。以下是一个简单的实现示例&#xff1a; <template><div class"article"><div v-if"isContentOverflow" :style"{ maxHeight:…

Python远程将文本、音频等数据写入Mysql或Redis附上云策略

Python远程将文本、音频等数据写入Mysql或Redis附上云策略 将文本、音频等数据存入MySQL或Redis,需要使用相应的数据库驱动和数据类型。 本篇分别针对MySQL和Redis的存储方法进行总结,附云存储策略: 1. 存入MySQL 1.1 文本数据入库 文本数据(例:TXT)可以直接作为字符串…

Vue列表渲染

一、Vue列表渲染 1.用 v-for 把一个数组对应为一组元素 我们可以用 v-for 指令基于一个数组来渲染一个列表。v-for 指令需要使用 item in items 形式的特殊语法&#xff0c;其中 items 是源数据数组&#xff0c;而 item 则是被迭代的数组元素的别名。 <ul id"exampl…

Facebook广告投放数据API对接流程

说明&#xff1a;仅供学习使用&#xff0c;请勿用于非法用途&#xff0c;若有侵权&#xff0c;请联系博主删除 作者&#xff1a;zhu6201976 一、需求背景 App在Facebook、Google等巨头进行广告投放&#xff0c;想要拿到实时广告投放效果数据&#xff0c;如曝光、点击、花费、触…

Django第三方功能的使用

Django第三方功能的使用 Django REST framework前言1、Django--Restframework--coreapi版文档BUG:AssertionError: coreapi must be installed for schema support.How to run Django with Uvicorn webserver?2、序列化类 Serializer的使用模型序列化类 ModelSerializer的使用…

4-安装并配置Grafana并导入特定的仪表板模板

要安装并配置Grafana并导入特定的仪表板模板&#xff0c;你可以按照以下步骤操作&#xff1a; 1. 安装Grafana 首先&#xff0c;确保你的系统中已安装了 yum&#xff0c;这通常是CentOS或RHEL及其衍生版本中的包管理器。然后&#xff0c;运行以下命令来安装Grafana Enterpris…

Axios的简明教程

Axios是什么&#xff1f; Axios是一个基于promise的HTTP客户端&#xff0c;可以在浏览器和node.js中使用。它提供了一种简单的方法来发送异步HTTP请求。与其他HTTP库&#xff08;如Fetch&#xff09;相比&#xff0c;Axios提供了更丰富的功能和更好的错误处理。例如&#xff0…