I have a small code which works fine on Chrome, Opera, Edge and Firefox. But it's not working on Safari.
I am a windows user so I not that familiar with Safari in order to find out what is wrong.
I was using this website as reference but I am not sure if it's updated or if maybe i could have misunderstood something. But I guess it suppose to work.
https://caniuse.com/?search=javascript%20modules
I am using apache and php
I have 3 files (index.php > index.js > Entities/Contato.js)
Tried to let it as simple as possible but let me know if you need anything else.
Thanks
index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<body>
<!-- This one works just fine -->
<script>
console.log('init');
</script>
<!-- This one does not work -->
<script type="module" src="./js/index.js"></script>
</body>
</html>
index.js
import {
ContatoEntity,
} from './Entities/Contato.js';
$(document).ready(()=>{
Main.ContatoCreate();
})
class Main {
static ContatoCreate(){
let contatoCreate = new ContatoEntity();
console.log(contatoCreate.getContatoId());
}
}
Contato.js
class ContatoEntity{
constructor(form) {
this.form = form;
}
#contatoId='123';
#contatoNome;
#telefones = [];
getContatoId(){
return this.#contatoId;
}
}
export {
ContatoEntity,
}
thanks again. I was trying different approaches and when I change the code I found a first error and when I searched for this error I found this 2 links which could kind of explain what is happenning. The thing is Safari Windows had its last release in 2010 Safari: SyntaxError: Use of reserved word 'class'
(portuguese - but not but explanation about versinos and stuff) https://support.apple.com/pt-br/102665
Thanks again Gonna change it to solved now