Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

363
Views
Error de referencia no detectado: función no encontrada en el módulo

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!