简体   繁体   English

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

[英]How to polyfill with native code in IE11?

As we all know that IE does not support Array.prototype.includes method, so it should log 'undefined' with Array.protopetype.includes.众所周知,IE 不支持 Array.prototype.includes 方法,所以它应该用 Array.protopetype.includes 记录 'undefined'。

However, open I open an app in IE which was built with vue-cli, and I tried to log ' Array.prototype.includes' in console, it unexpectedly log the 'native code', which means that the includes methods now was nativly supported!但是,打开我在 IE 中打开了一个使用 vue-cli 构建的应用程序,并且我尝试在控制台中记录“Array.prototype.includes”,它意外地记录了“本机代码”,这意味着现在包含的方法是本机的支持的!

Out of my perception,it should log something like function(){....}在我看来,它应该记录类似function(){....}

but how could it log 'native code'?I've googled that, but found nothing relative.Online link was showned here: https://gaoshijun1993.github.io/ ,you can test it with IE但是它怎么会记录'native code'?我用谷歌搜索过,但没有找到相关的。在线链接显示在这里: https : //gaoshijun1993.github.io/ ,你可以用IE测试它

在此处输入图片说明

Here is the code I used:这是我使用的代码:

 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; }

Here is the full program:这是完整的程序:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM