im struggling with Javascript, specifically with a module.
I recently created a file named Input.js wich is substantially my module, containing some function that i recall in another file located in the same directory.
the structure i created is like the one below
file input.js
export function foo(param){return hello;}
file main.js
import {foo} from './input.js';
function bar(param){
foo(param);
};
file index.hmt
<script src="main.js" type="module">
<button onclick="bar(this)"/>
the problem is that when i click the button javascript create an error:
Uncaught ReferenceError: foo is not defined at
HTMLElement.onclick
but i've already created the function.
Can anyone help me to figure out what i am doing wrong ?
thanks to everyone that can help me.
question from:
https://stackoverflow.com/questions/65862739/how-do-i-resolve-a-problem-with-a-function-imported-from-a-different-file-in-jav 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…