Vue工程调试方式

1,VScoed

首先安装Debugger fro Chrome

首先配置vue.config.js

module.exports = {
  configureWebpack: {
    devtool: 'source-map'
  }
}

然后配置VScode运行和调试

{
  // 使用 IntelliSense 了解相关属性。 
  // 悬停以查看现有属性的描述。
  // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "pwa-chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:8080",
      "webRoot": "${workspaceFolder}/src",
      "sourceMapPathOverrides": {
        "webpack:///src/*": "${webRoot}/*",
        "webpack:///./*": "${webRoot}/*",
      }
    }
  ]
}

可以开启断点调试了

2,vue-devtools

在谷歌浏览器安装插件vue devtools

有很多种配置vue devtools,这里介绍github安装方式

首先

git clone https://github.com/vuejs/vue-devtools.git

然后

cd vue-devtools
yarn install
yarn run build

打开谷歌浏览器

menu - more tools - extensions

打开developer mode

单击load unpacked

然后引入vue-devtools/packages/shell-chrome/

原文地址:https://www.cnblogs.com/sonwrain/p/14749636.html