Javascript file:
class Person2
{
constructor(name, age) {
this.name = name;
this.age = age;
}
getName() {
return this.name;
}
getAge() {
return this.age;
}
}
export default Person2;
Html with javascript:
<script type="module" src="Assets/testfunction.js">
import pers from "./testfunction.js";
let p = new pers("1", 1);
console.log(p.getAge());
</script>
If I remove type="module", I just get exceptions that there isn't a reference to pers, but when I include it, the code doesn't run. If I make it a simple script tag with just a console.log inside of it, it will run, and print.