Tengo mi estructura de archivos como esta:
classfile.js
class Car { constructor(name, year) { this.name = name; this.year = year; } }archivoprincipal.js
import {Car} from './classfile.js'; // Added this const myCar = new Car("Ford", 2014); function myFunction() { document.getElementById('demo').innerHTML = myCar.name + " " + myCar.year; }principal.html
<!DOCTYPE html> <html> <head> <script src="classfile.js"></script> <script type="module" src="mainfile.js"></script> </head> <body> <h2>JavaScript Class</h2> <p>How to use a JavaScript Class.</p> <p id="demo" onclick="myFunction()">Click Me</p> </body> </html>Sigo recibiendo errores myFunction() no está definido.
¿Cómo hago funciones en el tipo de módulo para ejecutar?