Angular组件在Internet Explorer 11上无法显示

3
我已经编写了一个使用Angular 4 Material 2的应用程序,在Chrome中一切正常,但在Internet Explorer中页面却是空白的。我在index.html中添加了一个<h1>标签,它可以显示出来,但是在我的content.component.html中添加<h1>标签却不起作用,即使整个组件的代码也没有被添加到DOM中。 index.html<h1>Test</h1> 在IE中能够显示):
<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <title>ITEM Projekte</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">

  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
</head>
<body>
  <h1>Test</h1>
  <app-root></app-root>
</body>
</html>

app.component.html<h1>Test</h1>在IE中不显示):

<h1>Test</h1>
<md-card>

  <md-card-title>ITEM Projekt anlegen</md-card-title>

  <md-card-subtitle>PROJEKTDATEN</md-card-subtitle>
  <md-card-content>
    <div style="width: 100%; ">
      <md-input-container *ngFor="let item of projektdaten" style="margin-right: 15px; display: inline-block; ">
        <label style="width: 120px; display: block;">{{item.identifier}}:</label><input mdInput name={{item.identifier}} style="width: 150px; " (keyup)="setProjectData(item, $event.target.value)">
      </md-input-container>
    </div>

    <div style="margin-top: 20px;">
      <md-radio-group>
        <md-radio-button value="1" style="margin-right: 30px; ">Neubau</md-radio-button>
        <md-radio-button value="2">Umbau</md-radio-button>
      </md-radio-group>
    </div>

  </md-card-content>

  <md-card-subtitle>MATERIALKOSTEN</md-card-subtitle>
  <md-card-content>
    <md-input-container><label>Test</label><input mdInput></md-input-container>
  </md-card-content>

  <md-card-subtitle>PERSONALKOSTEN</md-card-subtitle>
  <md-card-content>

  </md-card-content>

</md-card>

顺便提一下,在Edge浏览器中一切也都正常工作,但我需要它在IE浏览器中正常工作...如果您需要任何额外的代码,请告诉我。提前感谢您。

你在控制台收到了一个错误吗? - Christian
你导入了 polyfills 吗? - Vega
请查看以下链接:https://dev59.com/rVgQ5IYBdhLWcg3wMhLn - Amit Kumar Singh
@Christian 是的,在文件 polyfills.bundle.js 中,它说了类似于“触发接受并未被拦截”的内容。现在它已经可以工作了,谢谢。 - bene-we
那么问题是什么?pollyfills? - Vega
我已经在下面添加了解决方案,谢谢大家。 - bene-we
1个回答

5

我在这里找到了解决方案。

只需在polyfills.ts中删除以下行的注释即可:

/** IE9, IE10 and IE11 requires all of the following polyfills. **/

1
嗨。在我的情况下,注释上面的所有行都已经解除注释状态。尽管如此,我仍然看到一个空白页面,我的应用程序组件为空,并没有控制台错误。有任何想法吗?我需要添加ES7导入吗? - Aakash Kumar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接