【发布时间】:2018-10-01 15:35:09
【问题描述】:
我已经尝试过为此使用 npm run start 和 ng serve 。在所有情况下,生成的应用程序都无法在 IE11 和 Edge 中运行。
IE11 和 Edge 还存在许多其他问题,但这完全是关于 Angular CLI 在运行 ng serve 时无法有效包含 polyfill 的问题。
ng serve
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-10-01T15:27:24.006Z
Hash: f7ee38fccff1d585e3ed
Time: 12681ms
chunk {main} main.js, main.js.map (main) 119 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 452 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 86.4 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 7.2 MB [initial] [rendered]
i 「wdm」: Compiled successfully.
这是绝对必要的,因为我需要让我的应用程序完全兼容 IE11/Edge,而且我无法为生产环境构建以检查 div 居中是否有效。
编辑1:
运行 ng serve --prod 似乎确实有效,但是修改某些东西时速度很慢。仍然希望找到解决此问题的方法。
【问题讨论】:
-
你启用了所有的 IE11 polyfills 吗? (见angular.io/guide/browser-support#polyfill-libs)。另外,您的 tsconfig.json 目标是否设置为“es5”?
-
@Jolleyboy 如帖子中所述——是的,它们在使用 ng build --prod 和 ng serve --prod 时都可以工作——只有在运行 ng serve 时它才不起作用仍然很关键。
标签: angular angular-cli polyfills