简体   繁体   中英

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.

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.

The chapter on ES6 modules from the book exploring ES6 is the best resource I can recommend you at this point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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