vsCode 添加瀏覽器調試和js調試的方法總結

1、直接按F5可以調試的方法或者點擊運行按鈕(可以直接運行html文件或者js文件)

在launch.json文件中的配置如下:

{

    "version": "0.2.0",

    "configurations": [{

            "name": "谷歌瀏覽器", //運行html文件,用谷歌瀏覽器打開

            "type": "chrome",

            "request": "launch",

            "url": "${file}",

            "sourceMaps": true,

            "webRoot": "${workspaceRoot}"

        },

        {

            "name": "nodeLauch", //單獨調試js,即可以直接運行js

            "type": "node",

            "request": "launch",

            "program": "${file}", //這個配置成你要調試的文件、${file}當前打開的文件

            "stopOnEntry": false,

            "args": [],

            "cwd": "${workspaceRoot}",

            "runtimeExecutable": null,

            "runtimeArgs": [

                "--nolazy"

            ],

            "env": {

                "NODE_ENV": "development"

            },

            "console": "internalConsole",

            "preLaunchTask": "",

            "sourceMaps": false,

            "outDir": null

        }

    ]

}

2、第二種方法 Ctrl+Shift+B 快捷鍵運行html文件,在Tasks.json中配置如下:

{

    "version": "0.1.0",

    "command": "",

    "isShellCommand": false,

    "args": ["${file}"],

    "showOutput": "always",

    "windows": {

        "command": "C:/Users/shannonliang/AppData/Local/Google/Chrome/Application/chrome.exe"

    },

    "tasks": [{

        "taskName": "webserver",

        "isBuildCommand": true,

        "showOutput": "always"

    }]

}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章