ind*_*257 7 angular angular8 angular-cli-v8
我正在 angular8 中构建一个应用程序。我在 angular5/6/7 上工作,对于那些应用程序,我取消了对 polyfills.ts 中存在的导入的注释。对于 angular 8,它只有 3 个导入,即 classlist.js、web-animation-js 和 zone.js/dist/zone。我的应用程序在 IE 中运行良好。但是我开始使用包含功能来查看项目是否存在。它在 chrome 中运行良好。在 IE 中,它抛出 Object 不支持属性或方法 'includes' 错误。
小智 10
在polyfill.js添加下面一行:
import 'core-js/es7/array';
Run Code Online (Sandbox Code Playgroud)
includesArray.prototype是和上存在的函数,String.prototype但 IE 不支持它。您需要使用如下所示的polyfill:
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}
Run Code Online (Sandbox Code Playgroud)
或类似的数组。您还可以检查Core.js中的 polyfill
| 归档时间: |
|
| 查看次数: |
9859 次 |
| 最近记录: |