Javascript 文件未出现在 Chrome 开发人员工具中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31636271/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 14:06:37  来源:igfitidea点击:

Javascript files not appearing in chrome developer tools

javascriptgoogle-chrome

提问by jozxyqk

This happens periodically and has been for weeks. Most of the time everything's fine, but occasionally chrome simply doesn't show JS files. Visiting the same site via another URL or viewing in incognito can fix it. Restarting the server doesn't help. I'm pretty sure it's a problem with chrome (v43.0.2357.134v44.0.2403.107, still happens). I'm using django's runserver, though not sure it's relevant since the html is fine, validates at w3c and I can go to the js URL and load it.

这种情况定期发生,并且已经持续数周。大多数时候一切都很好,但偶尔 chrome 根本不显示 JS 文件。通过另一个 URL 访问同一站点或以隐身方式查看可以解决此问题。重新启动服务器没有帮助。我很确定这是 chrome 的问题(v43.0.2357.134v44.0.2403.107,仍然发生)。我正在使用 django's runserver,虽然不确定它是否相关,因为 html 很好,在 w3c 验证,我可以转到 js URL 并加载它。

enter image description here

在此处输入图片说明

I'm not even sure how to start debugging something like this. Is it a known bug with chrome? Perhaps some flag/setting that's wrong?

我什至不确定如何开始调试这样的事情。这是 chrome 的已知错误吗?也许某些标志/设置是错误的?



UPDATE:

更新:

If I have the debugger open when I refresh I get no js. otherwise it's fine.

如果我在刷新时打开调试器,则没有 js。否则没关系。

ANOTHER UPDATE:

另一个更新:

Here's my file structure:

这是我的文件结构:

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="test.js" ></script>
    </head>
    <body>
    </body>
</html>

Here's the javascript in test.js.

这是 .js 文件中的 javascript test.js

alert("hi");

When I refresh this page (opened by double clicking the file) with the debugger open, alertdoesn't run and the js file doesn't appear in the "Sources" tab. The same behaviour when inlining the js.

当我在调试器打开的情况下刷新此页面(通过双击文件打开)时,alert它不会运行,并且 js 文件不会出现在“源”选项卡中。内联 js 时的行为相同。

回答by jozxyqk

uncheck "disable javascript" and everything works

取消选中“禁用 javascript”,一切正常

Think this pretty much sums it up.

认为这几乎总结了它。

The Disable JavaScriptoption does not disable JS globally, but only when the dev tools are open on page load. Most of the time I was only bringing up the dev tools to check on a errors and inspect the page after it had loaded.

Disable JavaScript选项不会全局禁用 JS,但仅在页面加载时打开开发工具时才禁用。大多数时候我只是打开开发工具来检查错误并在页面加载后检查页面。

回答by HUDI Jashyawanta Huidrom

If it ever worked then, go to F1 (i.e) setting of the developer tool. then select (restore detauls and reload.) All should be fine

如果它曾经工作过,请转到开发人员工具的 F1(即)设置。然后选择(恢复细节并重新加载。)一切都应该没问题