Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

el-upload上传图片组件报错 #151

Closed
1 of 3 tasks
linj0218 opened this issue Jan 24, 2019 · 3 comments
Closed
1 of 3 tasks

el-upload上传图片组件报错 #151

linj0218 opened this issue Jan 24, 2019 · 3 comments

Comments

@linj0218
Copy link

linj0218 commented Jan 24, 2019

Issue Type:

  • Bug
  • Feature
  • Help

Version & Environment:

"dependencies": {
    "@angular/animations": "~7.1.0",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/core": "~7.1.0",
    "@angular/forms": "~7.1.0",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/router": "~7.1.0",
    "@types/swiper": "^4.4.1",
    "angularx-qrcode": "^1.5.1",
    "axios": "^0.18.0",
    "core-js": "^2.5.4",
    "element-angular": "^0.7.6",
    "rxjs": "^6.3.3",
    "rxjs-compat": "^6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.12.1",
    "@angular/cli": "~7.1.3",
    "@angular/compiler-cli": "~7.1.0",
    "@angular/language-service": "~7.1.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.6"
  }

Description:
使用el-upload组件上传图片的时候遇到问题,报:

"xhr.upload.addEventListener is not a function"

template:

<el-upload
  class="avatar-uploader"
  action="http://xxx.xxx.xx.xxx:8011/xx/imgUpload"
  [show-file-list]="false"
  (success)="successHandle($event)"
  (error)="errorHandle($event)"
>
  <ng-template #trigger>
    <img *ngIf="imgurl" [src]="imgurl" class="avatar">
    <i *ngIf="!imgurl" class="el-icon-plus avatar-uploader-icon"></i>
  </ng-template>
</el-upload>

javascript:

successHandle(file: any): void {
    console.log(file);
}
  
errorHandle(err: any): void {
  console.error(err);
  this.message.error('上传失败');
}

log:
wechatimg579

@linj0218
Copy link
Author

linj0218 commented Jan 24, 2019

错误信息:

{
  commonFile: {
    id: "0ceeade0",
    name: "WechatIMG2377.jpeg",
    percentage: 0,
    size: 203267,
    status: "fail"
  },
  error: {
    message: "xhr.upload.addEventListener is not a function",
    stack: "TypeError: xhr.upload.addEventListener is not a function
    at Observable._subscribe (http://0.0.0.0:8087/vendor.js:13360:32)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (http://0.0.0.0:8087/vendor.js:127227:25)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (http://0.0.0.0:8087/vendor.js:127213:22)
    at http://0.0.0.0:8087/vendor.js:138478:31
    at subscribeToResult (http://0.0.0.0:8087/vendor.js:138655:84)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub (http://0.0.0.0:8087/vendor.js:133412:90)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (http://0.0.0.0:8087/vendor.js:133406:14)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (http://0.0.0.0:8087/vendor.js:133389:18)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (http://0.0.0.0:8087/vendor.js:127846:18)
    at Observable._subscribe (http://0.0.0.0:8087/vendor.js:130025:20)"
  }
}

@linj0218
Copy link
Author

弃坑了,不用这个UI了,告辞

@linj0218 linj0218 closed this as completed May 4, 2020
@jirongliangss
Copy link

这个问题解决了吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants