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

265
Views
Importar un archivo JavaScript a otro archivo JavaScript que se importa a otro archivo

Necesito importar un archivo que importe código de otro archivo y luego importar ese archivo a un archivo final que agregue código a un botón HTML. ¿Cómo puedo hacer esto? Cuando intento con el siguiente ejemplo a continuación, no se ejecuta ningún código.

 // file 1 export function someFunction() { // more code } // file 2 import {someFunction} from './file1'; export function otherFunction() { someFunction(); // more code } // file 3 import {otherFunction} from './file2'; document.getElementById('some-button').onclick = otherFunction; // in index.html <script type='module' src='./file3.js'></script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La solución es incluir todos los archivos en index.html como type="module"

 <script type='module' src='./file1.js'></script> <script type='module' src='./file2.js'></script> <script type='module' src='./file3.js'></script>
about 4 years ago · Juan Pablo Isaza Report
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!