我在WebStorm中进行了以下配置设置:
当我点击调试时,它会很好地启动Chrome并导航到该页面,但我的断点永远不会受到影响。它以某种方式连接,因为我在WebStorm中看到了所有console.log()
输出。
我正在尝试导航到屏幕截图中指定的URL并且在main.js
中有断点,但它没有按预期工作(参见:at)。我不确定我错过了什么。我已经尝试在远程URL部分中为特定的main.js
文件设置远程URL,但这也没有帮助。
作为参考,我通过bra run
和npm run watch
运行应用程序。
快速更新
所以我已经能够实际获得一个断点,但它位于不同的文件中(在不同的路径中):
../public/app/core/routes/dashboard_loaders.ts
允许我在断点处停下来,但../public/dashboards
没有。
当我导航到http://localhost:3000/dashboard/script/main.js?orgId=1时,它击中了路线:
.when('/dashboard/:type/:slug', {
templateUrl: 'public/app/partials/dashboard.html',
controller : 'LoadDashboardCtrl',
reloadOnSearch: false,
pageClass: 'page-dashboard',
})
最终加载文件../public/dashboards/multi.js
- 但没有命中断点。
进一步更新
看起来脚本是通过the following command(在../public/app/features/dashboard/dashboardLoaderSrv.js
中)提供的:
/*jshint -W054 */
var script_func = new Function('ARGS','kbn','dateMath','_','moment','window','document','$','jQuery', 'services', result.data);
var script_result = script_func($routeParams, kbn, dateMath, _ , moment, window, document, $, $, services);
哪里$routeParams
是type:script
和slug:main.js
- 如果我进入这个函数,我得到一个匿名(?)文件,与我的实际main.js
文件相同,但名称就像43550
而不是main.js
- 我认为这是沸腾到一个基本缺乏JavaScript如何处理我的东西的知识。 :)
编辑:我发现这个issue for using webstorm with grafana(第二次编辑)看起来像这样。我认为他链接的内容通过声明sourceUrl来解决它,那么你的文件不是“匿名的”或者说是动态的。
//# sourceURL=filename.js
即
//# sourceURL=main.js
参考How to debug dynamically loaded JavaScript (with jQuery) in the browser's debugger itself?
以下是webstorm中有关调试的文档和视频,以确保一切正常。 (I.E我的默认设置是调试我的索引文件而不是我的项目)。确保你有他们的Chrome extension或Firefox Extension
General JS Debugging in Webstorm
Debugging for Chrome in Webstorm