未捕获的 TypeError:Object(...)(...).Class 不是函数
Posted
技术标签:
【中文标题】未捕获的 TypeError:Object(...)(...).Class 不是函数【英文标题】:Uncaught TypeError: Object(...)(...).Class is not a function 【发布时间】:2018-04-22 16:34:15 【问题描述】:在尝试实现此角度代码时,无法弄清楚为什么我会收到 TypeError。它会在 Class(constructor: function() ) 周围产生错误。不知道为什么。感谢您的帮助
import "hello_angular/polyfills";
import Component, NgModule from "@angular/core";
import BrowserModule from "@angular/platform-browser";
import FormsModule from "@angular/forms";
import platformBrowserDynamic from "@angular/platform-browser-dynamic";
var CustomerSearchComponent = Component(
selector: "shine-customer-search",
template: '\
<header> \
<h1 class="h2">Customer Search</h1> \
</header> \
'
).Class(
constructor: function()
);
var CustomerAppModule = NgModule(
imports: [ BrowserModule, FormsModule ],
declarations: [ CustomerSearchComponent ],
bootstrap: [ CustomerSearchComponent ]
)
.Class(
constructor: function()
);
【问题讨论】:
您使用的是哪个 Angular 版本? 我已经尝试过 ^5 和 ^4 github.com/angular/angular/issues/20305 【参考方案1】:尝试将 package.json
文件中的 Angular 版本更改为 4.1.3
"name": "shine",
"private": true,
"dependencies":
"@angular/common": "^4.1.3",
"@angular/compiler": "^4.1.3",
"@angular/core": "^4.1.3",
"@angular/forms": "^4.1.3",
"@angular/http": "^4.1.3",
"@angular/platform-browser": "^4.1.3",
"@angular/platform-browser-dynamic": "^4.1.3",
"@rails/webpacker": "^3.2.0",
"bootstrap": "3",
"coffeescript": "1.12.7",
"core-js": "^2.5.3",
"rxjs": "^5.5.6",
"ts-loader": "^3.2.0",
"typescript": "^2.6.2",
"zone.js": "^0.8.20"
,
"devDependencies":
"webpack-dev-server": "^2.9.7"
【讨论】:
以上是关于未捕获的 TypeError:Object(...)(...).Class 不是函数的主要内容,如果未能解决你的问题,请参考以下文章
text 错误:未捕获(在承诺中):TypeError:Object(...)不是函数
升级 Angular 项目后“未捕获的 TypeError:Object.setPrototypeOf 在 null 或 undefined 上调用”
JqueryUI 自动完成错误:未捕获的 TypeError:对象#<Object> 的属性“结果”不是函数
Vue:未捕获(承诺中)TypeError:无法读取未定义的属性'_c'