I have tried to export multiple variables, classes and functions, but I keep getting an error that I have to declare it. Is there any way I can get around this? Here’s the code.
JS:
var exports = [];
for(var module of exports) {
export module; //This gives me the error.
}
HTML:
<script type=“module” src=“main.js”></script>
CodePudding user response:
You can not do that because you are not allowed to do that.
Add export
to each symbol you want to export:
export var a = 1;
export function f(){}
Or
var a = 1;
function f(){}
export {
a,
f,
}