Windows系统Safari中Vanilla JavaScript ES6 Modules无法运行求助
问题:ES6模块在Windows版Safari中无法运行,其他浏览器正常
我编写的代码在Chrome、Opera、Edge和Firefox浏览器中均可正常运行,但在Windows系统的Safari浏览器里完全无法工作。作为Windows用户,我对Safari不熟悉,难以排查问题根源。此前我认为ES6 Modules应该能正常运行,但不确定相关兼容性信息是否更新,或是我存在理解偏差。
我使用Apache+PHP环境,涉及三个文件,代码如下:
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, }
若需要更多信息请告知,感谢帮助。
内容的提问来源于stack exchange,提问作者Jeú Casulo
相关产品推荐
相关产品推荐

