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

Docker builds jenkins+maven code building and deployment platform

Table of contents Docker Basic Concepts Docker in...

MySQL replication detailed explanation and simple example

MySQL replication detailed explanation and simple...

Issues and precautions about setting maxPostSize for Tomcat

1. Why set maxPostSize? The tomcat container has ...

How to implement digital paging effect code and steps in CSS

A considerable number of websites use digital pagi...

MySQL database terminal - common operation command codes

Table of contents 1. Add users 2. Change the user...

How to use http and WebSocket in CocosCreator

Table of contents 1. HttpGET 2. HTTP POST WebSock...

Detailed explanation of the difference between uniapp and vue

Table of contents 1. Simple page example 2.uni-ap...

How to get the maximum or minimum value of a row in sql

Original data and target data Implement SQL state...

Docker deployment and installation steps for Jenkins

First, we need a server with Docker installed. (I...

Is the tag li a block-level element?

Why can it set the height, but unlike elements lik...

Robots.txt detailed introduction

Robots.txt is a plain text file in which website ...