'How do I export multiple variables, classes or functions at one time?
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>
Solution 1:[1]
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,
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lee |
