zoukankan      html  css  js  c++  java
  • vsCode 添加浏览器调试和js调试的方法总结

    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"
        }]
    }

    3、如果第二种方法,不想每次都按这个快捷键,请参考npm配置node服务方法:

    http://stackoverflow.com/questions/30039512/how-to-view-my-html-code-in-browser-with-visual-studio-code 

  • 相关阅读:
    路由重分布(二)
    linux系统命令的收集 第一部分
    如何在VM软件中安装Linux系统
    Spring boot连接MongoDB集群
    jQuery中防止表单提交两次的方法
    Java中使用HTTP阻塞式调用服务器API
    本地项目初始化git推送到服务器
    前端页面调用Spring boot接口发生的跨域问题
    jQuery中异步问题:数据传递
    Git中修复bug
  • 原文地址:https://www.cnblogs.com/sxz2008/p/6690384.html
Copyright © 2011-2022 走看看