微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/js/157039.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐