Skip to content

Instantly share code, notes, and snippets.

@schaoss
Last active Nov 25, 2021
Embed
What would you like to do?
Force Open Vue Devtools
(() => {
// find root element: nuxt instance, #app, first div child in <body>
const root = window?.$nuxt?.$el || document.getElementById('app') || [...document.body.children].find(i => i.tagName === 'DIV');
const app = root?.__vue__;
if (!app || !window.__VUE_DEVTOOLS_GLOBAL_HOOK__) return 0;
const Vue = app.constructor;
const VueSuper = Vue.super || Vue;
VueSuper.config.devtools = true;
window.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue = VueSuper;
})()
/* bookmarklet
javascript:(function()%7Bconst%20root%20%3D%20window%3F.%24nuxt%3F.%24el%20%7C%7C%20document.getElementById('app')%20%7C%7C%20%5B...document.body.children%5D.find(i%20%3D%3E%20i.tagName%20%3D%3D%3D%20'DIV')%3Bconst%20app%20%3D%20root%3F.__vue__%3Bif%20(!app%20%7C%7C%20!window.__VUE_DEVTOOLS_GLOBAL_HOOK__)%20return%200%3Bconst%20Vue%20%3D%20app.constructor%3Bconst%20VueSuper%20%3D%20Vue.super%20%7C%7C%20Vue%3BVueSuper.config.devtools%20%3D%20true%3Bwindow.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue%20%3D%20VueSuper%7D)()
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment