【问题标题】:Error Uncaught (in promise): TypeError: Object(...) is not a functionError Uncaught (in promise): TypeError: Object(...) is not a function
【发布时间】:2020-03-25 05:05:55
【问题描述】:

每当我启动我的 Angular 应用程序时,都会出现此错误:

ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
    at default~app-app-module~9ca28b07.js:4519
    at Module../node_modules/cdk-table-exporter/fesm5/cdk-table-exporter.js (default~app-app-module~9ca28b07.js:4521)
    at __webpack_require__ (bootstrap:83)
    at Module../node_modules/mat-table-exporter/fesm5/mat-table-exporter.js (default~app-app-module~9ca28b07.js:5013)
    at __webpack_require__ (bootstrap:83)
    at Module../src/app/app-material.module.ts (default~app-app-module~9ca28b07.js:36901)
    at __webpack_require__ (bootstrap:83)
    at Module../src/app/app.module.ts (it.js:47)
    at __webpack_require__ (bootstrap:83)
    at main-wqrng.js?v=92fb42:43
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:17290)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)

我已经用 npm 尝试了 cdk-table-exporter 和 mat-table-exporter 但仍然给我这个错误。
这是 package.json 文件:

{
  "name": "webqreteang",
  "version": "1.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build p": "ng build --prod",
    "mock": "ng serve --proxy-config proxy/proxy.conf.json --open --host 0.0.0.0 --watch --configuration mock",
    "mock real be": "ng serve --proxy-config proxy/proxy.be.conf.json --port 4201 --open --host 0.0.0.0 --watch --configuration mock",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "7.2.15",
    "@angular/cdk": "7.3.7",
    "@angular/common": "^7.2.15",
    "@angular/compiler": "^7.2.15",
    "@angular/core": "^7.2.15",
    "@angular/forms": "^7.2.15",
    "@angular/http": "^7.2.15",
    "@angular/material": "7.3.7",
    "@angular/material-moment-adapter": "^7.3.7",
    "@angular/platform-browser": "^7.2.15",
    "@angular/platform-browser-dynamic": "^7.2.15",
    "@angular/platform-server": "^7.2.15",
    "@angular/pwa": "^0.7.1",
    "@angular/router": "^7.2.15",
    "@angular/service-worker": "^7.2.15",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@standard-coop/coop-stj-menu": "^7.0.0-beta.1",
    "@standard-coop/core": "^7.0.0",
    "@syncfusion/ej2-angular-richtexteditor": "^17.3.28",
    "angular-oauth2-oidc": "^5.0.2",
    "cdk-table-exporter": "^1.2.2",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.5.4",
    "devextreme": "^18.2.4",
    "devextreme-angular": "^18.2.4",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jquery": "^3.3.1",
    "mat-table-exporter": "^1.2.2",
    "moment": "^2.24.0",
    "node-sass": "^4.9.2",
    "rxjs": "^6.5.3",
    "rxjs-compat": "^6.0.0",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.11.0",
    "@angular-devkit/core": "^7.2.15",
    "@angular-devkit/schematics": "^7.2.15",
    "@angular/cli": "^7.3.9",
    "@angular/compiler-cli": "^7.2.15",
    "@angular/language-service": "^7.2.15",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "devextreme-cli": "1.0.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "json-server": "^0.12.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.2.4"
  }
}

【问题讨论】:

  • 请向我们展示您的 .ts
  • 似乎是兼容性问题。你确定你拥有这两个库的所有依赖项吗?
  • 尝试卸载@angular/cdk@angular/material(两个版本7.3.7)并尝试安装每个版本7.2.15。使用npm install @angular/material@7.2.15npm install @angular/material@7.2.15
  • @MattU 当我尝试安装它们时,它会给出错误No matching version found for @angular/material@7.2.15
  • 不知道你能不能保留7.3.7的@angular/material?

标签: angular angular7


【解决方案1】:

最新版本的 mat-table-exporter (1.2.2) 存在一个问题,该问题仅影响 Angular 7 及以下版本的用户。 你现在可以使用 1.2.1,会有一个版本解决这个问题。(issue 21)

编辑: 现在您可以使用最新版本 1.2.5

【讨论】:

    猜你喜欢
    • 2017-04-13
    • 2020-03-17
    • 2020-01-06
    • 2021-03-10
    • 2021-09-30
    • 2020-12-22
    • 2019-06-15
    • 2017-07-20
    • 1970-01-01
    相关资源
    最近更新 更多