Home >Web Front-end >JS Tutorial >Sharing the method of debugging Vue with breakpoints in Visual Studio Code
Many people are used to debugging Vue code in Chrome's debugging window, or directly using console.log to observe variable values. This is a very painful thing and requires at least 3 windows to be opened at the same time. Personally, I am more accustomed to breakpoint debugging. This article will introduce how to configure Visual Studio Code and Chrome to debug code directly at breakpoints in VS Code, and see the same console value in Chrome in the debugging window of VS Code.
Set Chrome remote debugging port
First we need to start Chrome with remote debugging turned on so that VS Code can attach to Chrome:
Windows
Right-click the Chrome shortcut icon and select Properties
In Target One column, add --remote-debugging-port=9222 at the end. Be careful to separate them with spaces
macOS
Open the console and execute:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
##Linux
Visual Stuido Code installation plug-in
{ // 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": "attach", "name": "Attach to Chrome", "port": 9222, "webRoot": "${workspaceRoot}/src", "url": "http://localhost:8080/#/", "sourceMaps": true, "sourceMapPathOverrides": { "webpack:///src/*": "${webRoot}/*" } } ] }
Modify the sourcemap of webpack
Start debugging
Must-see js breakpoint debugging experience sharing
Visual Studio Code vs. Node. Detailed explanation of the use of breakpoint debugging in js
Discussion on several methods of php breakpoint debugging
The above is the detailed content of Sharing the method of debugging Vue with breakpoints in Visual Studio Code. For more information, please follow other related articles on the PHP Chinese website!