简体   繁体   English

尝试在Rails 4中使用sprockets-es6使用'import'和'export'es6

[英]Trying to use 'import' and 'export' es6 using sprockets-es6 in Rails 4

I'm trying to use 'import' and 'export' keywords of es6 as explained on babeljs getting started using the sprockets-es6 gem in Rails 4. 我正在尝试使用es6的'import'和'export'关键字,正如babeljs开始在Rails 4中使用sprockets-es6 gem所解释的那样。

Can someone give an example of how to use it ? 有人可以举例说明如何使用它吗? I'm getting error saying 'import' should be present on top. 我收到的错误是“导入”应该出现在最顶层。

It will be easier to help if you could provide your code snippet and the stack trace of the error you are getting. 如果您可以提供代码片段以及您获得的错误的堆栈跟踪,那么将更容易提供帮助。

However based on the information you have provided, I am guessing you are not using import statement at top level, which the ES2015 Spec mandates. 但是,根据您提供的信息,我猜您没有在顶级使用import语句,这是ES2015规范要求的。

The chapter on ES6 modules from the book exploring ES6 is the best resource I can recommend you at this point. 本书探索ES6的 ES6模块章节是我可以推荐给你的最佳资源。

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

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