Answer the question
In order to leave comments, you need to log in
How to do import/export in js?
The essence of the error is that when I specify the type of the javascript file as modular, the functions stop working. Writes what
function is not definedIf you specify the type to text/javascript - the functions work, but the connection of modules stops working.
<script src="public/src/script.js" type="module"></script>
<button onclick="f()">
TEST
</button>
import {arr} from "./windows/Popup.js";
export function f() {
console.log(arr);
}
export let arr = 3.354;
Answer the question
In order to leave comments, you need to log in
If you change the code a bit to:
<button id="identify">
TEST
</button>
import {arr} from "./windows/Popup.js";
document.querySelector("#identify").addEventListener('click', () => {
console.log(arr);
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question