无法弄清楚为什么我在尝试实现此角度代码时会收到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() {}
});
答案 0 :(得分:0)
尝试将package.json
文件中的角度版本更改为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"
}
}