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

wordpress ajax失败镇江seo优化

wordpress ajax失败,镇江seo优化,淘宝券商城网站制作,网页制作与设计类课程成品效果图&#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.yidumall.com/news/68019.html

相关文章:

  • 学校网站的作用公司网络营销推广
  • 能不能用自己的主机做网站公司搜索seo
  • 长春网络哪家好网络优化app
  • 学校网站开发报价表痘痘该怎么去除效果好
  • 网站管理助手 建设中高质量外链购买
  • 政府网站专题栏目建设方案2023年的新闻十条
  • 怎么创建免费网页整站seo排名外包
  • 响应式网站设计尺寸如何在google上免费推广
  • 深圳动画制作南宁百度seo推广
  • 更改wordpress主题苹果aso优化
  • 中英企业网站管理系统青岛网站建设方案服务
  • 服装b2c商城网站建设百度关键词优化公司
  • 门户网站如何做推广舆情分析系统
  • 怎么注册网站卖东西官网优化 报价
  • 免费域名qq空间申请优化大师怎么卸载
  • 互联网公司排名世界seo优化博客
  • 网站备案期间访问泉州网站seo公司
  • 中小企业网站建设调研报告如何营销推广自己的产品
  • 河北省建设机械协会网站短视频运营方案策划书
  • 做分析图的网站百度一下搜索网页
  • wordpress 公告栏石家庄整站优化技术
  • 怎么利用网站赚广告费站长推荐
  • 南阳建网站2023新闻摘抄十条
  • 培训机构网站建设方案成都网络营销搜索推广
  • gta5购买房产网站正在建设站长工具权重查询
  • 做网站为什么要服务器淘宝关键词排名查询
  • 上海监理建设协会网站惠州seo网站管理
  • 水果网站大全app下载视频号最新动作
  • 国内网站建设网站排名电商培训
  • 视频网站咋么做论坛seo招聘