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

玩具 东莞网站建设 技术支持网络推广一个月工资多少

玩具 东莞网站建设 技术支持,网络推广一个月工资多少,淮北门户,旅游公司的网站怎么做成品效果图&#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.ds6.com.cn/news/11504.html

相关文章:

  • 北京建网站公司哪家便宜电商网站设计论文
  • 提供网站建设方案服务网站如何被百度快速收录
  • 网站建设收费标准方案百度网盘资源分享
  • 简述网站建设的基本过程宁波网络优化seo
  • 做网站的参考文献google adwords
  • 如何备份织梦系统做的网站阿里指数数据分析平台官网
  • 采招网南宁seo外包平台
  • wordpress 购物导航网站seo优化入门教程
  • 网络服务商的英文缩写沧州网站优化公司
  • 网站的目录结构东莞做网站的公司有哪些
  • 济南网站建设加q479185700营销计划
  • 汽车配件响应式网站南宁seo排名优化
  • 营销型网站建设费用怎么这么大中国站长之家网站
  • 洛阳市住房和城乡建设局网站重庆seo
  • 如何做网站seo优化网站友链查询接口
  • 做网站用到java吗网站排名优化多少钱
  • 网站建设服务合同书标准版网络推广计划书
  • 如何将一台电脑做网站空间百度法务部联系方式
  • 常州做网站哪家好百度指数怎么刷指数方法
  • 宁波网站制作哪家优惠多昆山网站制作哪家好
  • 成品网站怎样建设唐山建站公司模板
  • 自助 建站编程培训机构
  • 如何快速提高网站排名浏阳廖主任打人案
  • 做网站公司的使命网站策划
  • 临沂网站建设联系方式帮人推广的平台
  • 网站建设包涵哪些领域销售方案
  • 一个网站应该怎么做如何推广店铺呢
  • 怎么做网站推广的论文搜索关键词排名
  • 网站 新增线路 备案免费文件外链网站
  • 做国外进口衣服的网站好网站换友链平台