简体   繁体   English

Angular 4在IE11中不起作用

[英]Angular 4 not working in IE11

I'm working on an angular 4 app, when i open it with chrome, firefox or ie edge browser it runs whithout a problem, but when i open it with ie 11 it shows me this error in the browser's console 我正在使用angular 4应用程序,当我使用chrome,firefox或ie边缘浏览器打开它时,它没有任何问题,但是当我使用ie 11打开它时,它在浏览器控制台中显示了此错误

SCRIPT1003: ':' attendu common.chunk.js (922,22) SCRIPT1003:':'Attendu common.chunk.js(922,22)

ERROR Error: Uncaught (in promise): Error: Loading chunk common failed. 错误错误:未捕获(承诺):错误:加载大块公用失败。 Error: Loading chunk common failed. 错误:常见的加载块失败。 at Anonymous function ( http://localhost:8091/vendor.bundle.js:219834:17 ) at CatchSubscriber.prototype.error ( http://localhost:8091/vendor.bundle.js:136912:17 ) at Subscriber.prototype._error ( http://localhost:8091/vendor.bundle.js:134986:9 ) at Subscriber.prototype.error ( http://localhost:8091/vendor.bundle.js:134960:13 ) at OuterSubscriber.prototype.notifyError ( http://localhost:8091/vendor.bundle.js:134456:9 ) at InnerSubscriber.prototype._error ( http://localhost:8091/vendor.bundle.js:134005:9 ) at Subscriber.prototype.error ( http://localhost:8091/vendor.bundle.js:134960:13 ) at Subscriber.prototype._error ( http://localhost:8091/vendor.bundle.js:134986:9 ) at Subscriber.prototype.error ( http://localhost:8091/vendor.bundle.js:134960:13 ) at Subscriber.prototype._error ( http://localhost:8091/vendor.bundle.js:134986:9 ) 在订阅服务器上的CatchSubscriber.prototype.error( http:// localhost:8091 / vendor.bundle.js:136912:17 )的匿名函数( http:// localhost:8091 / vendor.bundle.js:219834:17 )处在OuterSubscriber上的Subscriber.prototype.error( http:// localhost:8091 / vendor.bundle.js:134960:13 )上的prototype._error( http:// localhost:8091 / vendor.bundle.js:134986:9 ) prototype.notifyError( HTTP://本地主机:8091 / vendor.bundle.js:134456:9 )在InnerSubscriber.prototype._error( HTTP://本地主机:8091 / vendor.bundle.js:134005:9 )中的订户。 Subscriber.prototype._error( http:// localhost:8091 / vendor.bundle.js:134986:9 )上的prototype.error( http:// localhost:8091 / vendor.bundle.js:134960:13 )发生在Subscriber.prototype._error( http:// localhost:8091 / vendor.bundle.js:134986:9 )的prototype.error( http:// localhost:8091 / vendor.bundle.js:134960:13

SCRIPT5022: SecurityError polyfills.bundle.js (5766,25) 脚本5022:SecurityError polyfills.bundle.js(5766,25)

polyfills.ts polyfills.ts

import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es7/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
import 'zone.js/dist/zone';

app.routes.ts app.routes.ts

import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
import { ModuleWithProviders } from '@angular/core';

export const routes: Routes = [
  { path: '', redirectTo: 'convention', pathMatch: 'full' },
  { path: 'network', loadChildren: './module/network/network.module#NetworkModule' },
  { path: 'convention', loadChildren: './module/convention/convention.module#ConventionModule' },
  { path: '**', redirectTo: 'convention' }
];

export const appRoutes: ModuleWithProviders = RouterModule.forRoot(routes, { useHash: true, preloadingStrategy: PreloadAllModules });

app.module.ts app.module.ts

@NgModule({
  imports: [
    CommonModule,
    CoreModule.forRoot(),
    NgbModalModule.forRoot(),
    appRoutes,
    StoreModule.forRoot(fromRoot.reducers),
    EffectsModule.forRoot([]),
    StoreDevtoolsModule.instrument({ maxAge: 50 })
  ],
  declarations: [
    ...APP_COMPONENT
  ],
  providers: [
    { provide: LocationStrategy, useClass: PathLocationStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

index.html index.html

<!DOCTYPE html>
<html>

<head>
  <title></title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
  <base href="/">
</head>

<body>
  <app-root>
    <div class="loader loader-site">
      <div class="logo-beidys-loader"></div>
    </div>
  </app-root>
</body>

</html>

Add meta tag in the index.html. 在index.html中添加元标记。 This is also a necessary line. 这也是必需的行。

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Please refer https://stackoverflow.com/a/6771584/7458082 for more infromation. 有关更多信息,请参阅https://stackoverflow.com/a/6771584/7458082

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM