0
When I try to import a console class from the browser, the following error appears:
Uncaught SyntaxError: Cannot use import statement outside a module
Filing cabinet models/Evento.js
:
export class Evento {
constructor(descricao, horaInicio, horaTermino){
this.descricao = descricao;
this.horaInicio = horaInicio;
this.horaTermino = horaTermino;
}
}
Filing cabinet view/eventos.js
:
import {Evento} from '../model/Evento';
function criarObjetoEvento(){
let id = localStorage.length + 1;
const descricao = document.getElementById("descricao").value;
const horaInicio = document.getElementById("horaInicio").value;
const horaTermino = document.getElementById("horaTermino").value;
const e = new Evento(descricao, horaInicio, horaTermino);
console.log(e);
criarEvento(e);
}
It is possible to realize import
and export
this way for files that will be run in the browser? Or is there another way to perform modulation?
In HTML, how do you import the module?
– Augusto Vasques