gpt4 book ai didi

javascript - Angular2 IE11 无法获取未定义或空引用的属性 'apply'

转载 作者:IT王子 更新时间:2023-10-29 02:51:25 26 4
gpt4 key购买 nike

将我的 angular2 包升级到以下版本后出现以下错误:

  • @angular/common": "^2.3.1
  • @angular/compiler": "^2.3.1
  • @angular/core": "^2.3.1
  • @angular/forms": "^2.3.1
  • @angular/http": "^2.3.1
  • @angular/platform-b​​rowser": "^2.3.1"
  • @angular/platform-b​​rowser-dynamic": "^2.3.1
  • @angular/platform-server": "^2.3.1
  • @angular/router": "^3.3.1

错误:无法获取未定义或空引用的“应用”属性

enter image description here

我只在 IE11 中遇到此错误,在 Chrome 中它工作正常。

我做了一些挖掘,导致错误的行在 angular/common 模块中:

function combine(options) {
return (_a = ((Object))).assign.apply(_a, [{}].concat(options));
var _a;
}

typescript 文件:

@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(组合([


更新

看来实际错误是.assign方法在IE11中没有实现

最佳答案

如果您正在使用 @angular/cli 并打算支持 IE9-11,您可以编辑 src/polyfills.ts 文件以启用适当的 polyfill。所需的 polyfill 已在文件中,因此您需要做的就是取消对它们的注释。

默认情况下,@angular/cli 项目以开箱即用的“常青”浏览器为目标,这意味着不会立即支持 IE,但您可以通过导入 polyfill 来添加对所需功能的支持。

关于javascript - Angular2 IE11 无法获取未定义或空引用的属性 'apply',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41276692/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com