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

网站建设服务哪家好唐山专业做网站

网站建设服务哪家好,唐山专业做网站,跨境电商综合服务平台有哪些,如何做淘宝网网站域名特别说明#xff1a;ui框架使用的是蚂蚁的antd 这里主要是学习前端上传接口的传递参数包括前端上传之前对于代码的整理 一、第一步将前端页面画出来 源代码#xff1a; /** 费用管理 - IT费用管理 - 费用数据上传 */ import { useState } from react; import {… 特别说明ui框架使用的是蚂蚁的antd 这里主要是学习前端上传接口的传递参数包括前端上传之前对于代码的整理 一、第一步将前端页面画出来 源代码 /** 费用管理 - IT费用管理 - 费用数据上传 */ import { useState } from react; import { WARNING_INFO } from /constants; import { InboxOutlined } from ant-design/icons; import { Button, Card, DatePicker, message, Spin, Upload, UploadProps } from antd; import dayjs from dayjs import ./index.less import { ITDataUpload } from /services/costControl;const DataUpload () {const [loading, setLoading] useStateboolean(false);const [fileList, setFileList] useStateany([]); //上传的文件列表const [dateString, setDateString] useStatestring(); // 数据日期// 文件组件属性const uploadProps: UploadProps {multiple: false,maxCount: 1,onChange(info) {},beforeUpload: (file) {console.log(上传文件, file);const regExp /^.*\.(?:xls|xlsx)$/iconst isExcel regExp.test(file.name)if (!isExcel) {message.error(WARNING_INFO.EXCEL_INFO);return Upload.LIST_IGNORE}// if (file.size 1024 * 1024 * 10) {// message.error(${file.name}大小不能超过10M);// return Upload.LIST_IGNORE;// }// 通过校验开始上传setFileList([file])// 阻止自动上传return false;},onRemove: () {//console.log(删除);setFileList([])},onDrop(e) {//console.log(Dropped files, e.dataTransfer.files);},};const handleUpload async (fileList: any) {if (!dateString) {message.error(请选择数据日期)} else {//console.log(时间,dateString);//console.log(文件,fileList);try {setLoading(true);let res await ITDataUpload({ date: dateString, file: fileList })//console.log(上传文件res, res);if (res?.code 200) {message.success(数据文件上传成功)setLoading(false);setFileList([])setDateString()} else {message.error(数据文件上传失败)setLoading(false);}} catch {setLoading(false);}}}const onChange (date: any, dateString: any) {setDateString(dayjs(dateString, YYYY-MM).format(YYYY-MM-01))}return (Spin tiploading... spinning{loading}Card bordered{false} style{{ width: 100%, minHeight: calc(100vh - 196px), paddingTop: 60px, paddingLeft: 80px }}div classNamedateControlspan classNametitle数据日期/spanDatePickeronChange{onChange}style{{ width: 200 }}pickermonthvalue{dateString ? dayjs(dateString) : } //divdiv classNameuploadAndDownloadspan上传文件/spanUpload.Dragger {...uploadProps}fileList{fileList}classNamedraggerStylep classNameant-upload-drag-iconInboxOutlined //pp classNameant-upload-text点击或者将文件拖拽到这里上传/pp style{{ color: #0000006e }}支持扩展名xlsx,xls/p/Upload.Dragger/divdiv classNamebuttonOptionButton typeprimary onClick{() {//console.log(点击提交, fileList);if (fileList.length 0) {handleUpload(fileList[0])} else {message.error(请上传文件)}}}提交/ButtonButton onClick{() {//console.log(点击重置);setFileList([])setDateString()}}重置/Button/div/Card/Spin) }export default DataUpload二、第二步将封装上传接口的函数整理出来这个是核心 源码 const handleUpload async (fileList: any) {if (!dateString) {message.error(请选择数据日期)} else {//console.log(时间,dateString);//console.log(文件,fileList);try {setLoading(true);let res await ITDataUpload({ date: dateString, file: fileList })//console.log(上传文件res, res);if (res?.code 200) {message.success(数据文件上传成功)setLoading(false);setFileList([])setDateString()} else {message.error(数据文件上传失败)setLoading(false);}} catch {setLoading(false);}}}三、第三步将封装的接口弄明白 源代码 export const ITDataUpload async (data: any) {return request(costControlApi.ITDataUpload, {method: POST,data,headers: { Content-Type: multipart/form-data },requestType: form,}) }四、第四步将上传接口弄明白 五、第五步将上传结果演示 呀这个就是整个的前端部分的文件上传需要注意的是对上传接口的处理其它的倒没有什么相对于文件下载需要对接收到的数据流还要处理而言整个文件上传还是异常简单的有没有感觉到。
http://www.w-s-a.com/news/691454/

相关文章:

  • 百度站长工具平台登录郑州seo规则
  • 财税公司做网站精品建站教程
  • 建设区块链网站区块链开发平台有哪些
  • 青年人爱看的网站ie显示wordpress网页不完整
  • 优惠券推广网站怎么做青岛正规网站建设哪家便宜
  • 怎么搞一个服务器建设网站wordpress页眉编辑
  • 计算机企业网站建设论文流量平台是什么意思
  • 成都建设网站公司哪家好上海有名的广告公司
  • 收录优美图片找不到了整站seo优化一般多少钱
  • 大型网站建设哪家好汉川网页设计
  • 深圳品牌策划公司推荐南昌网站怎么做seo
  • 滨州做微商城网站备案时暂时关闭网站
  • 手机网站样式代码网站是怎样制作的
  • 任务发布网站建设苏州园区房价
  • 网站的认识知识付费做的最好的平台
  • 企业电子商务网站设计的原则深圳的网站建设公司怎么样
  • 个人网站趋向wordpress图片搬家
  • 做空压机网站的公司有哪些wordpress 外部链接
  • 网站建设管理成本估计小红书推广平台
  • 一级a做爰片免费观看网站焦作建设企业网站公司
  • 欧阳网站建设2022华为云营销季
  • 快速学做网站高水平的大连网站建设
  • 专业做房地产网站建设wordpress侧面小工具
  • 旅游网站开发的重要性wordpress添加广告插件
  • 关于网站建设管理工作的报告婚纱网站php
  • 东莞市建设培训中心网站那个网站可以看高速的建设情况
  • 网站开发工具安卓版专业小程序商城开发
  • 网站不备案影响收录吗深圳住房网站app
  • 交网站建设域名计入什么科目开发平台教程
  • 个人网站定制北京快速建站模板