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

wordpress自建站邮箱net做公司网站

wordpress自建站邮箱,net做公司网站,14年网站开发经验,页面布局成品效果图&#xff1a; 解决问题&#xff1a;上传文件过大时&#xff0c;等待时间过长&#xff0c;但是进度条却不会动&#xff0c;只会在上传完成之后才会显示上传完成 上传文件的upload.component.html <nz-modal [(nzVisible)]"isVisible" [nzTitle]"文…

成品效果图:

解决问题:上传文件过大时,等待时间过长,但是进度条却不会动,只会在上传完成之后才会显示上传完成

上传文件的upload.component.html

<nz-modal [(nzVisible)]="isVisible" [nzTitle]="'文件上传'" [nzWidth]="'1000px'" [nzFooter]="modalFooter"(nzOnCancel)="onCancel()" class="advice-upload-file"><div nz-row><nz-upload #uploadListData nzType="drag" [(nzFileList)]="fileList" [nzMultiple]="isMultiple" [nzLimit]="0"[nzBeforeUpload]="beforeUpload"><p class="ant-upload-drag-icon"><i nz-icon nzType="inbox"></i></p><p>点击或拖拽上传</p></nz-upload><div style="padding-top: 10px"><h6>文件上传进度:</h6><nz-progress [nzPercent]="percent"></nz-progress></div></div><ng-template #modalFooter><button nz-button nzType="default" (click)="cleanList()">清空上传队列</button><button nz-button nzType="default" (click)="onCancel()">取消</button><button nz-button nzType="primary" (click)="submit()">上传</button></ng-template>
</nz-modal>

upload.component.ts

  /** 是否允许上传多个文件 */isMultiple = true;/*** 文件赋值列表*/fileList = [];/*** 上传进度条*/percent = null;/** 上传 */submit() {let successCount = 0;this.fileList.forEach(file => {const formData: FormData = new FormData();formData.append('file', file.originFileObj, file.name);this.uploadService.uploadMultiFiles(formData, this.categoryId, file.name).subscribe(data => {if (data) {successCount++;this.msg.create('success', data['fileName'] + `上传成功!`);this.percent = Number((successCount / this.fileList.length * 100).toFixed(2));}if (this.fileList.length === successCount) {setTimeout(() => {this.onCancel();this.notification.emit({operation: null,data: null});}, 1000);}});});}cleanList() {this.fileList = [];}beforeUpload = (file: UploadFile) => {// const isLt200M = file.size / 1024 / 1024 < 200;// if (!isLt200M) {//   this.msg.error('文件大小不超过200MB!');//   return false;// }return true;}

接口:

/** 上传文件 */uploadMultiFiles(files: FormData, categoryId: string, fileName: string): Observable<Array<any>> {return this.http.post(`${this.URL}` + `/uploadFile?fileName=${fileName}&categoryId=${categoryId}`, files);}

效果就是上传文件大时进度条一直是0%,然后上传完成才100%(会让用户误解没上传成功重复上传)

效果图:

解决方法如下:

1、修改接口里面的传参post,鼠标移上去一般有显示类型参数

  /** 上传文件 */uploadMultiFiles(files: FormData, categoryId: string, fileName: string): Observable<any> {return this.http.post(`${this.URL}` + `/uploadFile?fileName=${fileName}&categoryId=${categoryId}`, files, {}, {reportProgress: true,observe: 'events',});}

2、修改upload.component.ts 文件的提交方法

  /** 上传 */submit() {this.fileList.forEach(file => {const formData: FormData = new FormData();formData.append('file', file.originFileObj, file.name);this.uploadService.uploadMultiFiles(formData, this.categoryId, file.name).subscribe(event => {if (event.type === HttpEventType.UploadProgress) {this.percent = Math.round(100 * event.loaded / event.total);} else if (event.type === HttpEventType.Response) {// 文件上传成功this.msg.create('success', event.body['fileName'] + `上传成功!`);setTimeout(() => {this.onCancel();this.notification.emit({operation: null,data: null});}, 1000);}});});}

效果图:进度值会随着上传多少变化

参考文章:

angular:

https://www.yisu.com/jc/843309.html

axios:

https://www.jianshu.com/p/9564b549d2d6

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

相关文章:

  • 健身器材网站源码wordpress主题免刷新
  • 现在推广网站最好的方式档案安全网站安全建设
  • 重庆长寿网站设计公司推荐网站没备案可以使用了吗
  • 再网站里做商家店铺用模块做网站
  • 网站开发用主要软件天津网站开发公司电话
  • wordpress网站嵌入音乐seo要点
  • 传媒有限公司免费网站果壳 wordpress
  • 专业做网站较好的公司广州站点怎么建网页
  • 更换网站需要怎么做做电商网站必需知道qc
  • 特色企业网站wordpress 短链插件
  • 绍兴网站建设做网站域名138查询网
  • 二手车网站开发多少钱logo图片设计
  • 北京专业制作网站公司哪家好站外推广渠道
  • 网站建设许可证学校的网站怎么做的好
  • 做娃衣的布料去哪个网站郑州网络公司排名前十名
  • 成都哪个公司做网站网页版游戏链接
  • 珠海市住房城乡建设局网站做网站注册35类哪几个小项
  • 网站下方链接图标怎么做中企动力销售一个月能挣多少
  • 诸暨企业网站建设企业首页网站属于什么类型网站
  • 太湖县网站建设公司下载京东购物商城app
  • 北京微信网站建设费用深圳网站建设运营
  • 企业网站设计与规划论文网站维护是什么职位
  • 不得不知道的网站网站网址有哪些
  • 杭州网站排名服务知名网站建设企业
  • 横向网站网站怎样推广 优帮云
  • 为什么想做网站运营素材网站设计模板下载
  • 怎样给网站或者商品做推广京东官网首页入口
  • 如何做一个大型网站杭州做网站比较好的公司
  • 电子商务网站规划与网页制作网页图片另存为的时候保存不了jpg
  • 做软欧的网站网站开发与维护书