Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

225
Vistas
importing a class returns error and breaks my existing function

I'm trying to import script.js into my app.js and it returns an error that says "Uncaught SyntaxError: import not found: script app.js:1:9" and also breaks getSelectedItems function and says that is also undefined. I included my HTML because I'm unsure if there could be an error there.

I'm trying to import this into 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>

This is from my 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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda