将我的 angular2 包升级到以下版本后出现以下错误:
- @angular/common”: “^2.3.1
- @angular/编译器”: “^2.3.1
- @angular/核心”: “^2.3.1
- @angular/表格”: “^2.3.1
- @angular/http”: “^2.3.1
- @angular/平台浏览器”: “^2.3.1”
- @angular/platform-browser-dynamic”: “^2.3.1
- @angular/平台服务器”: “^2.3.1
- @angular/路由器”: “^3.3.1
错误: Unable to get property 'apply' of undefined or null reference
我只在 IE11 中收到此错误,在 Chrome 中它工作正常。
我做了一些挖掘,导致错误的行在 angular/common 模块中:
function combine(options) {
return (_a = ((Object))).assign.apply(_a, [{}].concat(options));
var _a;
}
打字稿文件:
@angular/common/src/pipes/intl.ts 第 175 行
function combine(options: Intl.DateTimeFormatOptions[]): Intl.DateTimeFormatOptions {
return (<any>Object).assign({}, ...options);
}
调用 combine
函数的代码是 @angular/common/src/pipes/intl.ts 第48行:
'yMMMdjms': datePartGetterFactory(combine([
更新
看来实际错误是 .assign
方法没有在IE11中实现
原文由 Tjaart van der Walt 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果您正在使用
@angular/cli
并打算支持 IE9-11,您可以编辑src/polyfills.ts
文件以启用适当的 polyfill。所需的 polyfill 已在文件中,因此您需要做的就是取消对它们的注释。默认情况下
@angular/cli
项目以开箱即用的“常青”浏览器为目标,这意味着不立即支持 IE,但您可以通过导入 polyfills 来添加对所需功能的支持。