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

219
Views
importar una clase devuelve un error y rompe mi función existente

Estoy intentando importar script.js a mi app.js y devuelve un error que dice "Error de sintaxis no detectado: importación no encontrada: script app.js:1:9" y también interrumpe la función getSelectedItems y dice que tampoco está definido. Incluí mi HTML porque no estoy seguro de si podría haber un error allí.

Estoy tratando de importar esto en app.js

 export class script { //Save movies into the local storage saveIntoStorage(item) { const items = this.checkStorage(); items.push(item); // Add new array into the localStorage localStorage.setItem("items", JSON.stringify(items)); } // return movies from storage checkStorage() { let items; // Check the localStorage if (localStorage.getItem("items") === null) { items = []; } else { items = JSON.parse(localStorage.getItem("items")); } return items; } }
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>My Website</title> <link rel="icon" href="./favicon.ico" type="image/x-icon"> </head> <body> <main> <h1>Welcome to My Website</h1> </main> <script src="app.js" type="module"></script> <script src="script.js" type="module"></script> </body> </html>

Esto es de mi app.js

 import { script } from "./script.js"; // Store the user input from dropdown menu into a new array function getSelectedItems() { const items = document.getElementsByClassName("selectVal"); myApp.results = []; for (let i = 0; i < items.length; i++) { const item = items[i]; const userInput = item.options[item.selectedIndex].value; myApp.results.push(userInput); } }

about 4 years ago · Santiago Gelvez
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!