一个脚本在 vue 的生产环境下,使用Devtools 调试工具
__VUE_DEVTOOLS_GLOBAL_HOOK__.emit('init', (document.querySelector('#app').__vue__.__proto__.__proto__.constructor.config.devtools = true) && document.querySelector('#app').__vue__.__proto__.__proto__.constructor)
部分 vue 版本只需要进行一次._proto_ 运算就能拿到constructor
__VUE_DEVTOOLS_GLOBAL_HOOK__.emit('init', (document.querySelector('#app').__vue__.__proto__.constructor.config.devtools = true) && document.querySelector('#app').__vue__.__proto__.constructor)
如果不存在#app 节点时用以下方法也可以,总之就是拿到vue 的实例就行了
__VUE_DEVTOOLS_GLOBAL_HOOK__.emit('init', ($0.__vue__.__proto__.__proto__.constructor.config.devtools = true) && $0.__vue__.__proto__.__proto__.constructor)