You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 21:19:57