0
import and export modules are not working!?
I am trying to use the import and export feature of js. Here are my files and codes ----------------------------------------------- module.js var x =10; export {x} export.js import x from './module.js' alert(x);
3 ответов
+ 2
{x} is equivalent to {x:10} since x=10
Try alert(x.x); you would get a value of 10
0
Yes..also how to import those modules in a normal HTML file. I have tried to import by writing it as the first statement. But there's an error as ' import declaration may not appear at top level of a module'. One more question : do I need to include the file of js using script src .. or it will work just by import?
0
Move all import declarations to top of the lines.