我遇到了同样的问题,它仍然存在于 Angular 中。
错误原因
SyntaxError: Multiple definitions of a property not allowed in strict mode
原因是:你都添加了styleUrls
and styles
到一个组件。
您可以在粘贴的 webpack 捆绑代码中清楚地看到它们,即styles
属性创建了 2 次。
奇怪的是只有 IE 11 有问题:)
Solution
重新排列您的样式并删除styles
or styleUrls
。只留下其中之一。
IE11 中组件损坏的示例
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
// with both `styleUrls` and `styles` IE11 crashes
styles: [`
h2 {
color: red;
}
`]
})
export class AppComponent {}
重现环境
我已经在新的 Angular 版本上检查过了,仍然存在问题:
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0