简体   繁体   English

如何在Chrome开发者工具中的JavaScript调试的部分视图中调试脚本?

[英]How to debug a script inside partial view that load by javascript in Chrome Developer Tools?

When I loaded html file that contains javascript code by using the following code 当我使用以下代码加载包含javascript代码的html文件时

$("#containerId").load("@Url.Action("ActionName")"); $( “#数据筒”)负载( “@ Url.Action(” ActionName “)”)。

I couldn't find it in the chrome source tab I find out chrome renames js-loaded file to something like "VM27123" that the number changed by every refresh and chrome does not show these files in search result 我在chrome来源标签中找不到该文件,发现chrome将js加载的文件重命名为“ VM27123”之类,每次刷新更改的数字,chrome不会在搜索结果中显示这些文件

so how can I find them and set breakpoint on it? 那么如何找到它们并在其上设置断点?

omatase's answer : omatase的答案

use the syntax: 使用语法:

//# sourceURL=fileName.cshtml

immediately after opening your script tag. 打开脚本标记后立即进行。 Example: 例:

<script type="text/javascript">
    //# sourceURL=fileName.cshtml
    function foo() {}
</script>

and you can find your javascript in sources tab on debug mode by fileName 并且您可以通过fileName在调试模式下的“源”选项卡中找到您的javascript

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

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