In a personal project I am using html to "host" a js application (a basic calculator), after some updates the js script doesn't load... I've checked the console and it gives me this error:
在一个个人项目中,我正在使用html来“托管”一个js应用程序(一个基本的计算器),在一些更新之后,js脚本没有加载……我检查了控制台,结果显示以下错误:
The resource from “http://127.0.0.1:5500/bhaskara/assets/js/bhaskara.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
由于MIME类型(““http://127.0.0.1:5500/bhaskara/assets/js/bhaskara.js”/html”)不匹配(X-Content-Type-Options:NoSniff),来自文本的资源被阻止。
I found some related questions about this and did some tests but nothing worked.
我找到了一些与此相关的问题,并做了一些测试,但都没有奏效。
1 Test: I put a Type tag in the (DID NOT WORK)
1测试:我把一个类型标签在(不工作)
Before:
之前:
<script src="../bhaskara/assets/js/bhaskara.js"></script>
After
之后
<script type="text/javascript" src="../bhaskara/assets/js/bhaskara.js"></script>
2 Test: Change the location (DID NOT WORK)
2测试:更改位置(不起作用)
Before:
之前:
<body>
<tags>
<tags>
<script src="../bhaskara/assets/js/bhaskara.js"></script>
</body>
After
之后
<head>
<script src="../bhaskara/assets/js/bhaskara.js"></script>
</head>
I am really out of Ideas on how to fix this....
我真的没有办法解决这件事了……
更多回答
This is a problem on the server that you are hosting the javascript file with on port 5500. It returns the mime type header "text/html" along with your javascript file. Instead it should return the "text/javascript" header. What server software are you using?
这是您在端口5500上托管Java脚本文件的服务器上的一个问题。它返回MIME类型的头文件“Text/html”和您的Java脚本文件。相反,它应该返回“Text/javascrip”头。您使用的是什么服务器软件?
I am using the Live Server (VS CODE).
我使用的是Live Server(VS代码)。
Solved! Just for the record it was not the Vs live code but the browser I was using... Apparently I running it in Chrome solves the issue... (Mozilla Firefox Developer Edition does not like Js LOL.
解决了!顺便说一句,不是VS LIVE代码,而是我使用的浏览器…显然,我在Chrome上运行它解决了这个问题。(Mozilla Firefox Developer Edition不喜欢Js LOL。
我是一名优秀的程序员,十分优秀!