Browser Compatibility
ES2015 import/export functionality is currently fully supported in the following browser versions and later (check caniuse.com for the most up-to-date list):
Enabling Module Support in Older Browsers
For older browser versions, you may need to enable certain flags:
Can ES2015 Import Work in Firefox?
Despite placing your import statement at the top level of your t1.js file, you encounter the error: "SyntaxError: import declarations may only appear at top level of a module." This suggests that Firefox may not be fully supporting ES2015 import functionality.
Understanding the Correct Top-Level Requirement
While your import statement is located at the beginning of t1.js, it is crucial to note that the file itself must explicitly indicate that it's loaded as a module. Simply placing the import statement at the top of a non-module file will not suffice.
How to Enable Module Loading in Firefox
To resolve the issue, you need to add the "type" attribute to your script tag, specifying that it's a module:
Browser Compatibility
ES2015 import/export functionality is currently fully supported in the following browser versions and later (check caniuse.com for the most up-to-date list):
Enabling Module Support in Older Browsers
For older browser versions, you may need to enable certain flags:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3