简体   繁体   English

Chrome开发者工具来源未正确显示javascript文件

[英]Chrome developer tools sources not showing javascript files correctly

I'm very new to JavaScript, jQuery, and JSON browser debugging. 我是JavaScript,jQuery和JSON浏览器调试的新手。 But I do know that the "Sources” tab in chrome dev tools is supposed to let me look at my JavaScript files in the browser so I can set and manage my breakpoints and effectively debug my code. 但我知道chrome dev工具中的“Sources”选项卡应该让我在浏览器中查看我的JavaScript文件,这样我就可以设置和管理断点并有效地调试我的代码。

However, when i press Ctrl + Shift + I to open chrome dev tools, i can't see a list of my javascript files under the Sources tab. 但是,当我按Ctrl + Shift + I打开chrome dev工具时,我无法在Sources选项卡下看到我的javascript文件列表。

I only something in the form of... 我只有...的形式...

jslib.axd?=jquery-.7.2.min.js,query.validate.min.js,MyRegion.js,MyCountry.js,MyCategory.js

...which looks like a concatenated list of all my javascript files. ...看起来像我所有的javascript文件的连接列表。 But what i was expecting to see is a list of each of my javascript files. 但我期待看到的是我的每个javascript文件的列表。

Screenshot: 截图:

在此输入图像描述

It looks like you have used a compression tool to combine all of your javascript files. 您似乎使用了压缩工具来组合所有javascript文件。 What you see is not an error in Chrome - it's just all of your script files combined into one. 你看到的不是Chrome中的错误 - 它只是将所有脚本文件合并为一个。

If you are still developing, just turn off whatever tool you are using to compress them (at least until you are finished your dev work). 如果您仍在开发中,只需关闭您正在使用的任何工具来压缩它们(至少在您完成开发工作之前)。 This will allow your scripts to load individually on the page. 这将允许您的脚本在页面上单独加载。

Then you can use chrome dev tools to see each file listed. 然后,您可以使用chrome dev工具查看列出的每个文件。

If you want to set a break point. 如果要设置断点。 Use 'debugger' in your code like so : 在代码中使用'debugger',如下所示:

//code here
debugger;

I never use Chrome to debug javascript but i'm sure you can do it easilly. 我从不使用Chrome来调试javascript,但我相信你可以轻松地做到这一点。 Firebug in firefox is great and you can also debug in Visual studio if you use IE with 'debugger'. Firefox中的Firebug很棒,如果你使用IE和'debugger',你也可以在Visual Studio中调试。

Hope this help. 希望这有帮助。

If you use chrome/firefox just press f12 it will open web development tool 如果你使用chrome / firefox只需按f12它将打开web开发工具

now go to source/script section and select the js file in which you want to add a break point 现在转到source / script部分并选择要在其中添加断点的js文件

just click on that line to add break point not run the function it will come to your break point and then you can debug through F10 for singe line and move for next break point press F8 只需点击该行即可添加断点而不会运行它将进入断点的功能然后您可以通过F10调试单线并移动到下一个断点按F8

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

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