IE array.flat() 对象不支持属性或方法“平面" [英] IE array.flat() Object doesn't support property or method 'flat'

查看:38
本文介绍了IE array.flat() 对象不支持属性或方法“平面"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从谷歌浏览器访问我的网站时一切正常(也在移动设备上).但是当尝试从边缘\移动普通浏览器(不是谷歌浏览器)访问时我明白了

When accessing my website from google chrome everything works fine(also on mobile). but when trying to access from edge \ mobile normal browser(not google chrome) i get

TypeError: Object doesn't support property or method 'flat'

试图访问一个函数 .flat 的数组.

trying to access a function .flat of array.

事实证明它根本不存在于原型中.我能用它做什么?子数组定义为

turns out that it dosent exist on the proto at all. what can i do with it? the childs array is defined as

`let childs = [];`

(前端使用 react)

(using react for front end)

推荐答案

IE 不支持 Array.prototype.flat().您可以使用 reduceconcat 作为解决方法:

IE does not support Array.prototype.flat(). you can use reduce and concat as a workaround:

childs = childs.reduce((acc, val) => acc.concat(val), [])

这篇关于IE array.flat() 对象不支持属性或方法“平面"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆