avatarDerick Sozo Ruiz

Summary

The website content discusses the utility of Vue DevTools for accelerating Vue.js application development through live component data editing, Vuex state management debugging with time-travel, and custom event tracking.

Abstract

The article "Speed up development with Vue DevTools" outlines how Vue developers can enhance their debugging process and increase efficiency using the Vue DevTools plugin. It emphasizes three key features: the ability to live edit component data directly within the browser, facilitating quick testing without the need to repeatedly modify and refresh code; the integration with Vuex for time-travel debugging, which allows developers to navigate through the application's state changes; and the tracking of custom events emitted within the application, providing insights into the event flow. The article also provides installation instructions for different environments, including Chrome, Firefox, and an Electron app, and directs readers to further resources for in-depth exploration of Vue DevTools capabilities.

Opinions

  • The author suggests that using console.logs for debugging Vue.js apps is less efficient compared to leveraging Vue DevTools.
  • Live editing of component data is presented as a superior alternative to manual code modifications, as it eliminates the need for a repetitive change-refresh cycle.
  • The integration of Vue DevTools with Vuex is highly praised for its ability to perform time-travel debugging, underscoring the predictable nature of state management with Vuex.
  • The article conveys that the ability to export and import entire Vuex state objects can be particularly useful for replicating and resolving issues that users encounter.
  • The Vue DevTools' Events pane is recommended as a convenient tool for monitoring custom events in real-time, which can simplify the debugging of event handling in Vue applications.
  • The author encourages readers to explore additional features and updates of Vue DevTools by referring to the "What’s New in Vue DevTools 4.0" article and the official Vue DevTools GitHub repository.

Speed up development with Vue DevTools

Are you still using console.logs to debug your Vue.js apps? Vue has a dedicated plugin that can help speed up your development. It doesn’t replace your logs — it complements them. It’s called Vue DevTools and here are 3 ways you can use it to speed up the development of your Vue apps.

Installing the Vue DevTools Plugin

Before we jump in, there are 3 versions of the DevTools that you can install depending on your environment. There’s a Chrome Plugin, a Firefox addon, and there’s even an Electron app (works with Mac, Linux, and Windows) that you can download as well.

Click here to see specific installation instructions for each version of the plugin on the DevTools GitHub page.

Once you have the plugin installed, open your browser’s developer tools and then open up the Vue DevTools plugin on a page that is using the development version of Vue, the VueJS docs for example is using the development version of Vue.

Now, let’s jump in and see the 3 ways that you can use the Vue DevTools to speed up the development time of your applications.

1. Live edit your component data

One very convenient feature of the Vue DevTools is live editing your component’s data. This lets you quickly test different variations of your component.

You’re not in your IDE, manually modifying component values in your code anymore. Instead, live editing component data allows you to skip the whole change-refresh-change-refresh dance in your IDE to speed up your development time.

In order to live-edit your component’s data, first click the component you want to edit in the component pane of the Vue DevTools. After clicking, you’ll see a data tab appear with all the data the component has access to. You can edit text values, easily toggle booleans off and on, increment numbers, and even add values to an array.

Editing a component’s data live works even if you’re using a remote API to fetch your data. Once your data comes from the server and loads, it will be available for you to edit in the Vue DevTools Components pane.

2. Debug Vuex with Time Travel

Vue DevTools integrates seamlessly with the Vuex state management library by visualizing it’s predictable nature.

The Vuex state management library is a centralized object store for all the components in your Vue.js application. This store can only be mutated in a predictable way using functions to create new versions of your state instead of modifying values directly.

This allows you to do what’s known as time-travel debugging and The Vue DevTools makes it easy for you to cycle through previous versions of your Vuex state object.

To access this part of the tools, first click on the Vuex clock icon. In here you can go through all of the different mutations that have occurred in your application. After hovering over a mutation, click on the Time Travel button to go back to that state.

Another convenient Vue DevTools feature for Vuex is how you can export and import entire state objects. This can be useful for debugging an issue a user is experiencing that you’re not able to recreate.

3. Track your app’s custom events

If you’re using events in your application you can track them inside of the events tab of the Vue DevTools.

This allows you to keep track of your app’s events, but it only displays your app’s custom events, e.g. the ones that you emit yourself with this.$emit(‘myEvent’), and not the ones natively bound to the component like v-on:click or v-on:keyup.

To start tracking your apps’ custom events, click on the Events pane of the Vue DevTools. Afterwards, click on the Record button and you’ll start seeing your custom events appear in the left pane as you go through your application.

Learn more about the Vue DevTools

Those are 3 ways that the Vue DevTools can help speed up your development. There’s a lot more that it can help you with when it comes to debugging.

To learn more about the specifics of what you can do with The Vue DevTools read the What’s New in Vue DevTools 4.0 published on The Vue Point.

Also, if you’re having trouble with installation visit the Vue DevTools Github repo.

Subscribe to our newsletter and get our free Vue Essentials Cheat Sheet!

Keep Reading

JavaScript
Vuejs
Debugging
Devtools
Vue Devtools
Recommended from ReadMedium