How to use Webstorm and Chrome to debug Vue projects

How to use Webstorm and Chrome to debug Vue projects

Preface

In project development, Debug mode is very necessary. Debug mode is very convenient for the backend IDEA tool, but for the frontend WebStorm, if Debug mode is enabled, some things need to be configured separately.

So here I organize the process of successful construction and share it. Different Webstorm versions may result in different results, so here is my version first.

Webstorm version: 2018.3.4

1. Create a new Vue project

In order to demonstrate a complete example, start by creating a project. Here, we use the vue scaffolding command to create a project.

vue init webpack debug-vue

If the run is successful, a Vue project named debug-vue will be created. We open this project through WebStorm and run it, starting the command

npm run dev

View the page after successful startup

This means that the project runs successfully. Here we add a button to the code. We will click this button later to see if the Debug mode can successfully reach the breakpoint.

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <h2>Home</h2>
    <button @click="testMethods">Test bug breakpoint</button>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },
  methods:{
    testMethods: function () {
      alert("Click me and I'll pop up")
    }
  }
}
</script>

After the change, check the page again and it will look like this

It is obvious that when you click this button, a box will pop up, indicating that the click event is bound successfully.

2. WebStorm Configuration

1. Set the debugger port

2. Add debug configuration

Webstorm is now configured.

3. Testing

first step

First add a breakpoint in the specified code, then start the project

Step 2

Start the project, command

npm run dev

After successful startup

Step 3

Start the debug button configured above

Step 4

test

The above is the details of how to use Webstorm and Chrome to debug Vue projects. For more information about Vue, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • WebStorm cannot correctly identify the solution of Vue3 combined API
  • How to run a Vue project with Idea or webstorm (detailed steps)
  • Set resolves.alias: ''@'' path based on vue project and adapt to webstorm
  • A fool-proof tutorial on how to build a vue-cli scaffold in webstorm
  • Solve the problem that the Webpack alias cannot be used in Vue cli scaffolding projects under Idea and WebStorm
  • How to initialize the project with webstorm+vue
  • vue: How to set up fast compilation and running in WebStorm
  • Detailed explanation of Vue syntax support in WebStorm
  • Solution to es6 syntax errors in webstorm and .vue
  • Vue template configuration and webstorm code format specification settings

<<:  Methods and problems encountered in installing mariadb in centos under mysql

>>:  Mysql sorting to get ranking example code

Recommend

Two ways to implement HTML page click download file

1. Use the <a> tag to complete <a href=&...

Detailed explanation of top command output in Linux

Preface I believe everyone has used the top comma...

Detailed explanation of views in MySQL

view: Views in MySQL have many similarities with ...

MySQL 5.7.21 installation and configuration tutorial under Window10

This article records the installation and configu...

Things to note when writing self-closing XHTML tags

The img tag in XHTML is so-called self-closing, w...

Some wonderful uses of URL objects in JavaScript

Table of contents Preface Parsing parameters Modi...

Summary of MySQL character sets

Table of contents Character Set Comparison Rules ...

In-depth understanding of slot-scope in Vue (suitable for beginners)

There are already many articles about slot-scope ...

Solution to find all child rows for a given parent row in MySQL

Preface Note: The test database version is MySQL ...

The basic principles and detailed usage of viewport

1. Overview of viewport Mobile browsers usually r...

WeChat applet uses canvas to draw clocks

This article shares the specific code of using ca...

How to convert extra text into ellipsis in HTML

If you want to display extra text as ellipsis in ...