Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda