如何在IE11中使用本机代码进行填充?

问题描述 投票:1回答:1

我们都知道IE不支持Array.prototype.includes方法,因此它应该使用Array.protopetype.includes记录“未定义”。

[但是,打开后,我在用vue-cli构建的IE中打开了一个应用程序,我试图在控制台中记录'Array.prototype.includes',它意外地记录了'本机代码',这意味着现在包括方法得到天真的支持!

出于我的理解,它应该记录类似function(){....}

但是它怎么会记录'本机代码'?我已经在Google上进行了搜索,但没有发现任何相对的内容。在线链接显示在此处:https://gaoshijun1993.github.io/

enter image description here

javascript webpack babel vue-cli-3
1个回答
0
投票

这是我使用的代码:

 if (!Array.prototype.includes) //Dirty-fix za starije preglednike koji ne podrzavaju JavaScript naredbu Array.includes (kao sto je Internet Explorer 6).
                Array.prototype.includes = function (x)
                {
                    for (var i = 0; i < this.length; i++)
                        if (this[i] == x)
                            return true;
                    return false;
                }

这里是完整程序:

https://github.com/FlatAssembler/ArithmeticExpressionCompiler/blob/master/compiler.html

© www.soinside.com 2019 - 2024. All rights reserved.