技术解析
使用 vue-cli3 的脚手架,默认配置了 polyfill 了.我在 index.html 中手动重置 Array.prototype.includes 为 undefined, 然后在组件中使用 Array.includes 方法,然后在控制台中打印 Array.prototype.includes,打印出来的结果均为 fuction () {native code}
这让我觉得有点不可思议,对于 chrome 来说,因为 includes 方法本身就是 native support 的,我重置后,babel 还可以通过 iframe 来恢复,可是对于 ie 来说,本来就没有对 includes 方法支持,按道理打印出来的应该是 polyfill 的代码而不是 native code,babel 怎么实现这种黑魔法的?