vConsole Vue DevTools Plugin

1.0.9 · active · verified Sun Apr 19

vue-vconsole-devtools is a specialized plugin designed to embed the official Vue.js DevTools directly into vConsole, a lightweight front-end developer tool primarily used for debugging mobile web pages. This enables developers to inspect Vue component states, props, events, and Vuex/Pinia stores directly within a mobile browser's vConsole interface, obviating the need for a desktop browser's Vue DevTools extension. The current stable version is 1.0.9. Releases are infrequent, focusing on compatibility fixes with newer versions of vConsole and Vue DevTools. Its key differentiator is providing a fully integrated Vue debugging experience in environments where traditional browser extensions are unavailable or impractical, such as WebView or mobile Safari/Chrome without remote debugging capabilities. It is framework-agnostic for its vConsole integration but specifically targets Vue.js applications for its debugging capabilities.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `vue-vconsole-devtools` with `vConsole` and a basic Vue 2.x application, ensuring that Vue DevTools is correctly initialized and available within the vConsole interface.

import Vue from 'vue';
import VConsole from 'vconsole';
import { initPlugin } from 'vue-vconsole-devtools';

// 1. Initialize vConsole first
const vConsole = new VConsole();

// 2. Initialize the vue-vconsole-devtools plugin
// This must be called before creating your Vue root instance.
initPlugin(vConsole);

// 3. For Vue 2.x, ensure devtools is enabled and emit the global hook
// This makes Vue DevTools aware of your Vue instance. 
// This step is crucial for the plugin to detect your Vue application.
Vue.config.devtools = true;
if (window.__VUE_DEVTOOLS_GLOBAL_HOOK__) {
  window.__VUE_DEVTOOLS_GLOBAL_HOOK__.emit("init", Vue);
}

// 4. Create your Vue application
const app = new Vue({
  data() {
    return {
      message: 'Hello vConsole Vue DevTools!',
      counter: 0
    };
  },
  template: `
    <div>
      <h1>{{ message }}</h1>
      <button @click="counter++">Increment: {{ counter }}</button>
      <p>Check the vConsole panel for Vue DevTools tab.</p>
    </div>
  `
});

app.$mount('#app');

// Optional: Append a root element for the Vue app if not already in HTML
if (!document.getElementById('app')) {
  const el = document.createElement('div');
  el.id = 'app';
  document.body.appendChild(el);
}

console.log('vConsole and Vue DevTools plugin initialized. Look for the "Vue" tab in vConsole.');

view raw JSON →