javascript – es6模块原生支持

前端之家收集整理的这篇文章主要介绍了javascript – es6模块原生支持前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我理解ES6模块规范,问题在于它的支持. AFAIK,没有本机实现此功能的浏览器(请参阅浏览器兼容性 here).有几个问题:

>显然,ES6模块是ES6功能.当我看到kangax compatibility table时,我根本看不到这样的行(对于ES6模块),为什么呢?这是ES6的一个功能
>因此,现在使用ES6的唯一方法是使用构建工具,例如babel,browserify或任何其他替代品,对吧?
>当它们被本机支持时,如何从浏览器中调用异步AJAX来获取模块?

解决方法

ES6 modules is an ES6 feature,obvIoUsly. When I look at kangax compatibility table,I don’t see such row (for ES6 modules) at all,why is that?

在kangax的github上有an issue being discussed.

the only way to use ES6 right now is to use a build tool,such as babel,browserify or any other aternative,right?

不,Guy Bedford在http://github.com/ModuleLoader/browser-es-module-loader还有一个polyfill.

而且已经有Edge的预览版本可以在本地实现它.

how are the modules gonna be fetched,when they’re natively supported – as async AJAX calls from the browser?

是但不完全相同:通过调用导入库上的对象(函数属性),第一次使用它们时将获取它们.

原文链接:https://www.f2er.com/js/157039.html

猜你在找的JavaScript相关文章