Chrome的F12開發者工具,在Source
標簽頁可以對js的某行打斷點進行調試。
當頁面和js是iframe引入的,可能會找不到頁面對應的js文件。
解決方法:
- 切換
JavaScript Context
,如圖:
- 在頁面的頂部增加
//@ sourceURL=Xxx.js
,其中Xxx.js
是對應的js文件名; - 在js文件里需要打斷點的地方增加行
debugger;
。
參考:
如何瀏覽器里調試iframe里層的代碼?https://blog.csdn.net/weixin_34146986/article/details/89051215
使用Chrome開發人員工具調試iframe https://www.imooc.com/wenda/detail/600179
https://stackoverflow.com/questions/3275816/debugging-iframes-with-chrome-developer-tools
chrome調試工具使用之js篇 https://blog.csdn.net/userkang/article/details/85252644