对象不支持属性或方法'填充'

632*_*324 9 javascript

我在网上找不到同样的问题.IE 11给出错误"对象不支持属性或方法fill".

var arr = new Array(5);
arr.fill(false);
Run Code Online (Sandbox Code Playgroud)

有没有方便的方法来填充数组而不是使用for循环?谢谢.

Ali*_*avi 18

我面临同样的问题,不要添加任何东西.

只需打开polyfills.ts文件并取消注释以下行:

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
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/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
Run Code Online (Sandbox Code Playgroud)

每件事都会开始奏效.


Ber*_*rgi 11

安装普通的polyfill并继续使用.fill(…).