Angular 2+:IE11中严格模式下不允许对属性进行多个定义

贝辛格

我有pollyfills,并且在main.bundle.js中从Internet Explorer 11中收到此错误。它在9692行上,但查看编译后的代码,我无法理解它。这里是:

    styles: ["\nng-select-custom >>> .caret {\n  /* display: none; */\n}\nng-select-custom >>> .ui-select-match-text {\n  white-space: normal;\n  line-height: 21px;\n}\nng-select-custom >>> .ui-select-toggle {\n  overflow: hidden;\n}\n"]

这是Angular 2+的常见问题吗?我没有看到有关NG2 +的任何帖子。

更新:这是有关代码的更多上下文:

DropdownRuleInputComponent = __decorate([
    __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
        selector: 'dropdown-rule-input',
        template: "\n  <ng-select-custom\n    [class.invalid]=\"invalidShowing\"\n    [items]=\"items\"\n    [active]=\"activeSelection\"\n    (selected)=\"selection = $event\"\n    placeholder=\"Click for options\">\n  </ng-select-custom>\n  ",
        styles: [__webpack_require__("../../../../../../pushgraph-client/lib/search/rule-inputs/default-styles.sass")],
        styles: ["\nng-select-custom >>> .caret {\n  /* display: none; */\n}\nng-select-custom >>> .ui-select-match-text {\n  white-space: normal;\n  line-height: 21px;\n}\nng-select-custom >>> .ui-select-toggle {\n  overflow: hidden;\n}\n"]
    }),
    __metadata("design:paramtypes", [typeof (_d = typeof __WEBPACK_IMPORTED_MODULE_3__shared_search_service__["a" /* SearchService */] !== "undefined" && __WEBPACK_IMPORTED_MODULE_3__shared_search_service__["a" /* SearchService */]) === "function" && _d || Object])
], DropdownRuleInputComponent);
米卡楚姆

我有同样的问题,它仍然存在于Angular中。

错误原因

SyntaxError: Multiple definitions of a property not allowed in strict mode

原因是:您已将styleUrls都添加styles到一个组件中。您可以在粘贴的Webpack捆绑包代码中清楚地看到它们,该styles属性被创建2次。

奇怪的是,只有IE 11才有问题:)


重新排列样式,然后删除stylesstyleUrls只留下其中之一。

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

严格模式下不允许属性的多个定义-Angular

Angular2 IE11无法获取未定义或空引用的属性“应用”

防止IE11在Angular 2中缓存GET调用

Angular 2性能IE11 * ngFor

c#-405(不允许使用方法)从Angular 2应用进行POST时

不允许使用Angular2多个构造函数实现TS2392

Vivado Sim错误:“在Verilog 95 / 2K模式下不允许进行根范围声明”

Angular Material 2选项卡标签中的输入不允许空格

ng 构建失败,并在 Angular2 中显示“不允许操作,mkdir”\dir”

在Edge浏览器中,严格模式下不允许分配只读属性

Angular2 OnInit不触发IE11

angular2 *ngFor 对象数组 IE11 错误

Angular2打字稿中的箭头功能-IE11

带有Angular2的IE11中的Object.assign()

Angular 2的IE错误

Angular 2多个模块

Angular 2+:IE 11无法获取未定义或空引用的属性“调用”

Angular Web Api 2不适用于POST:405方法不允许

URL Angular2 +打字稿Webapp不允许使用405方法

IE11在Angular2(TS)中发布Angular CLI项目,polyfill无法正常工作

Angular 2中的多个模块

Angular 2中的Fancybox

在Angular 2中循环

Angular 2异常:TypeError:严格模式函数或arguments对象上的'caller','callee'和'arguments'属性

我是否需要任何特定说明才能使 Angular2 with Bootstrap 在 IE11 和 Safari 中工作?

使用模式Angular 2进行输入验证

IE 11中的Angular 2 HTTPs POST错误

Angular 2 of-class 在 IE 11 中不起作用

angular:6打字稿:2 primeng:7导致“在环境中不允许使用cli初始化程序”