不要直接双击打开 HTML 文件。
浏览器在 file:// 协议下会拦截 ES 模块与 Web Crypto,导致页面空白、加密按钮不出现。
这是浏览器的安全限制,不是 bug。
请先在项目目录启动一个本地服务器(端口号随意,下面只是示例),然后用它给出的地址打开:
- Python 3:
python -m http.server 8000
- Node:
npx serve .
- VS Code:右键
index.html →「Open with Live Server」
例如从 tools/html-encryptor/ 的上一层启动后,访问
http://127.0.0.1:8000/tools/html-encryptor/index.html;
若直接从 tools/html-encryptor/ 内启动,则访问
http://127.0.0.1:8000/index.html。
部署到线上后,直接用线上地址即可。