简体   繁体   English

Javascript 在本地主机上工作,但在部署 github 页面或 vercel 时停止

[英]Javascript works on localhost, but it stops on deploy github pages or vercel

Can someone tell me why the javascript works on localhost, but when using github Pages or vercel, the javascript stops?有人能告诉我为什么 javascript 可以在 localhost 上运行,但是当使用 github Pages 或 vercel 时,javascript 会停止吗?

code on github: https://github.com/Marincor/Bx-Bank github上的代码: https : //github.com/Marincor/Bx-Bank

Deploy githubpage: https://marincor.github.io/Bx-Bank/部署github页面: https ://marincor.github.io/Bx-Bank/

Deploy on Vercel: https://bx-bank.vercel.app/在 Vercel 上部署: https : //bx-bank.vercel.app/

when I go to the dev tools source of the pages index.html and cadastro.html they don't have the JS folder that I have linked.当我转到页面 index.html 和 cadastro.html 的开发工具源时,他们没有我链接的 JS 文件夹。

print of devTools chrome sourcers tab打印 devTools chrome 源标签

print of github JS folder github JS文件夹的打印

print of the script src inside the html file在 html 文件中打印脚本 src

i don't know what to do, any tips?我不知道该怎么办,有什么建议吗?

for some reason, the home.html works the javascript file, just index.html and cadastro.html doesn't.出于某种原因,home.html 可以处理 javascript 文件,只有 index.html 和 cadastro.html 不能。

Format the path to your script file with a preceding ./ like you do with your css links:使用前面的./格式化脚本文件的路径,就像处理 css 链接一样:

<script type="module" src="./Assets/JS/Index.js"></script>

Edit: and be aware of casing:编辑:并注意大小写:

<script type="module" src="./Assets/JS/index.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM