简体   繁体   English

手表在vscode中不起作用? (Vuejs)

[英]Watches not working in vscode? (Vuejs)

It took me a while to get the debugger to work within Visual Studio Code. 我花了一些时间才能使调试器在Visual Studio Code中工作。 Now the program breaks on set breakpoints inside of .vue files/components. 现在,程序在.vue文件/组件内部的设置断点处中断。 But none of the watches seem to work. 但是这些手表似乎都不起作用。 They are either undefined or unavailable, even when the variables have been created. 即使已创建变量,它们还是未定义或不可用。

The settings I use in launch.json : 我在launch.json使用的设置:

{   
    "name": "chrome debug",
    "type": "chrome",
    "request": "launch",
    "port": 3000,
    "url": "http://localhost:3000/admin",
    "webRoot": "${workspaceFolder}",
    "breakOnLoad": true
    // "sourceMapPathOverrides": {
    //     "webpack:///src/*": "${webRoot}/*"
    // }
}

I build my app through npm run build or npm run devbuild which, by my knowlegde, 'compiles' the .vue components into Javascript files. 我通过npm run buildnpm run devbuild构建应用程序,据我npm run devbuild ,这将.vue组件“编译”为Javascript文件。 And then start the app with either npm start or nodemon index.js . 然后使用npm startnodemon index.js启动应用程序。

Package.json Package.json

  "scripts": {
    <...>
    "build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
    "devbuild": "cross-env NODE_ENV=development webpack --progress --hide-modules",
    <...>
  },

例

Have you ever tried add a new script with nodemon? 您是否尝试过使用nodemon添加新脚本? Something like this: 像这样:

"newScript": "nodemon -L -e ts,json --watch . --exec \\"npm run build || “ newScript”:“ nodemon -L -e ts,json --watch。--exec \\” npm运行build || npm run devbuild\\"" npm运行devbuild \\“”

-L = Though this should be a last resort as it will poll every file it can find. -L =虽然这应该是最后的手段,因为它会轮询它可以找到的每个文件。 -e = By default, nodemon looks for files with the .js, .mjs, .coffee, .litcoffee, and .json extensions. -e =默认情况下,nodemon查找扩展名为.js,.mjs,.coffee,.litcoffee和.json的文件。 If you use the --exec option and monitor app.py nodemon will monitor files with the extension of .py. 如果使用--exec选项并监视app.py,nodemon将监视扩展名为.py的文件。 However, you can specify your own list with the -e (or --ext) switch like so: nodemon -e js,jade --watch . 但是,您可以使用-e(或--ext)开关指定自己的列表,如下所示:nodemon -e js,jade --watch。 = To watch all the changes on the path, in this case all the code on the current path. =要监视路径上的所有更改,在这种情况下,是当前路径上的所有代码。 (I got all of this information from the documentation . (我从文档中获得了所有这些信息。

then, run the command: 然后,运行命令:

npm run newScript npm运行newScript

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM