一、調試准備
Windows10 64bits
IDE:Visual Studio Code1.28.2
安裝插件:Chrome(安裝方法:Debug -> Install Additional Debuggers... -> Debugger for Chrome,重新啟動vscode即可。)
二、調試配置
首先該插件運行需要安裝有本地服務器,其次有兩種配置方式,分別為:
(1)launch:重新打開一個chrome來顯示應用程序
(2)attach:在已經運行的chrome中顯示應用程序
2.1、Launch配置
按F5並選擇chrome進入配置文件launch.json,我的Launch配置如下所示:
"version": "0.2.0", "configurations": [ { "type": "chrome", "request": "launch", "name": "Launch Chrome against localhost", "url": "http://localhost/文件路徑", "webRoot": "${workspaceFolder}" } ]
2.2、Attach配置
attach的launch.json配置如下所示:
{ "type": "chrome", "request": "attach", "name": "Attach to Chrome", "port": 9222, "sourceMaps": true, "webRoot": "${workspaceFolder}" }
字由https://www.wode007.com/sites/73248.html 中國字體設計網https://www.wode007.com/sites/73245.html
步驟一:讓chrome進入調試模式:
方法一:在命令行中進行設置:
路徑/chrome.exe --remote-debugging-port=9222
方法二:chrome桌面圖標右鍵 -> 屬性 -> 目標 -> 在路徑后面添加 --remote-debugging-port=9222 即可。
其中 --remote-debugging-port 的值與lanuch.json中的 port 的值要匹配。然后在瀏覽器中打開本地服務器上的web頁面
步驟二:在vscode中打開調試按鈕進行調試,即可進入調試模式。
