使用VSCode调试Vue.js

一、效果展示

说明:这个是通过chrome浏览器开放一个远程调试端口来实现的

 

二、具体步骤

1. VSCode安装插件 Debugger for Chrome

2. 打开配置文件 launch.json

把默认的覆盖掉,写成下面的(官方给的配置里没写"runtimeExecutable"这行,我的多写了一个chrome的路径,因为不写的话,我的会报找不到chrome.exe)

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "vuejs:chrome",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}/src",
            "runtimeExecutable": "C:/Program Files (x86)/Google/Chrome Dev/Application/chrome.exe",
            "breakOnLoad": true,
            "sourceMapPathOverrides": {
                "webpack:///./src/*": "${webRoot}/*",
                "webpack:///src/*": "${webRoot}/*",
                "webpack:///*": "*",
                "webpack:///./~/*": "${webRoot}/node_modules/*"
            }
        }
    ]
}

3. 开启chrome远程调试端口

我复制了一个chrome快捷方式,然后把目标改成了

"C:\Program Files (x86)\Google\Chrome Dev\Application\chrome.exe" --remote-debugging-port=9222

关掉所有打开的chrome窗口,重新打开chrome浏览器

4. 需要调试的地方打上断点,然后点击绿色三角形,就会进到断点了

 

参考链接:

https://vuejs.org/v2/cookbook/debugging-in-vscode.html

https://github.com/Microsoft/vscode-recipes/tree/master/vuejs-cli

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值