Code Monkey home page Code Monkey logo

vue-devtools-plugin's Introduction

# Vue-devtools-plugin

Vue-devtools-plugin 是一款vConsole & Eruda 插件,把Vue.js官方调试工具vue-devtools移植到移动端,可以直接在移动端查看调试Vue.js应用

Preview

CodePen Sample Code for Vue2

CodePen Sample Code for Vue3

桌面使用:

Desktop Desktop 移动端使用:

Mobile

为什么需要本插件:

  1. 在任意浏览器和移动端上查看调试Vue.js应用
  2. 无需在浏览器安装Vue-devtools插件
  3. 支持Vue2 & Vue3

功能

  1. 移植了官方Vue-devtools的全部功能
  2. 针对移动端优化了部分操作方式
  3. 现已支持微信端内浏览器

使用方式

NPM方式引入

  1. vConsole: yarn add vue-vconsole-devtools --dev Eruda: yarn add eruda-vue-devtools --dev
  2. 在工程中入口文件 (如src/main.js
...
// vconsole
import VConsole from "vconsole";
import { initPlugin } from 'vue-vconsole-devtools' // for vconsole

initPlugin(new VConsole()); // 需要在创建Vue根实例前调用
...
...
// eruda
import { initPlugin } from 'eruda-vue-devtools' // for eruda
import eruda from 'eruda' // 引入工具包

eruda.init() // 初始化
initPlugin(eruda); // 需要在创建Vue根实例前调用
...
  1. 如果devtools中没有加载出你的应用 请添加如下代码
// Vue 2.x
Vue.config.devtools = true;
window.__VUE_DEVTOOLS_GLOBAL_HOOK__.emit("init",Vue)

CDN方式引入

<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue_plugin.js"></script>
<script>
  var vConsole = new window.VConsole();
  const Devtools = window.vueVconsoleDevtools
  Devtools.initPlugin(vConsole);
</script>

高级用法

  1. 只在开发环境下引入

    new Vue({
      render: (h) => h(App),
    }).$mount("#app");
    
    // 在创建跟实例以后调用, 需要借助webpack的异步模块加载能力
    if(process.env.NODE_ENV === "development"){
       Promise.all([import("vconsole"), import("vue-vconsole-devtools")]).then(
         (res) => {
           if (res.length === 2) {
             Vue.config.devtools = true;
             window.__VUE_DEVTOOLS_GLOBAL_HOOK__.emit("init",Vue)
             const VConsole = res[0].default;
             const Devtools = res[1].default;
             Devtools.initPlugin(new VConsole());
           }
         }
       );
     }

更新日志

1.0.9

  1. 兼容了vConsole 3.14之后的新版本
  2. 更新Vue-devtools 6.5.0 支持更新的功能
  3. 更新之后解决了遗留的一些问题

v1.0.5

  1. 兼容CDN引入,优化引入方式
  2. 兼容ES6 解构运算符引入方式

v1.0.0

  1. 重大更新,升级Vue-devtools V6
  2. 兼容Vue3

v0.0.7

  1. 重要更新,解决iOS微信端浏览器兼容性问题
  2. 解决iOS阿里mPass容器兼容性问题

v0.0.3

  1. 优化了打包体积

### Sample code

Github

欢迎添加微信 **OmniBug **探讨交流,Email: [email protected]

vue-devtools-plugin's People

Contributors

xch1029 avatar zippowxk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-devtools-plugin's Issues

插件识别不了装饰器写法的vue组件名称

vue版本2.x
Chrome 的vue-dev-tool 版本5.3.4

使用vue-property-decorator支持的TS写法,在线上环境中识别不了组件名称
@Component export default class ComponentName extends Vue {}
具体表现为
image

但是在dev本地开发环境上是可以识别的到组件名称

通过cdn的方式引入,控制台报错

我在项目中通过cdn的方式引入

<script>
      // 通过链接参数或者sessionStorage开启调试
      (function () {
        if (!/debug=true/.test(window.location) && sessionStorage.getItem('debug') !== 'true') return;
        document.write('<script src="https://unpkg.com/vconsole" onload="new window.VConsole()"><\/script>');
        document.write('<script src="https://unpkg.com/vue-vconsole-devtools" onload="window.vueVconsoleDevtools.initPlugin(VConsole.instance);"><\/script>');
      })();
</script>

启动项目控制台报错

[Error] TypeError: null is not an object (evaluating 'l.contentWindow')
	onReady (vue_plugin.js:1:12825040)
	trigger (vue_plugin.js:1:128227)
	(匿名函数) (vconsole.min.js:10:278259)
	(匿名函数) (vconsole.min.js:10:276647)
	a (vconsole.min.js:10:274886)

指定[email protected]版本无此报错;

启动vue-devtools在safari浏览器(版本16.1 )报错:

TypeError: undefined is not an object (evaluating 'browser.runtime.onMessage.addListener')

具体可看我的仓库https://github.com/zhang-shaoqiang/uni-app-vite.git

项目无法运行

这个项目需要npm,node,yarn分别什么版本 才可以跑起来?

在Vue3项目中使用,报错:无法找到模块“vue-vconsole-devtools”的声明文件

代码:

// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import VConsole from "vconsole"
import { initPlugin } from 'vue-vconsole-devtools' // 这句代码报错

import './assets/main.css'

new VConsole()
// initPlugin(new VConsole())

createApp(App).mount('#app')

具体的报错信息如下:

无法找到模块“vue-vconsole-devtools”的声明文件。“/Users/nimohe/Documents/web-space/vue3-study/ts-vue3-demo/node_modules/vue-vconsole-devtools/dist/vue_plugin.js”隐式拥有 "any" 类型。
尝试使用 npm i --save-dev @types/vue-vconsole-devtools (如果存在),或者添加一个包含 declare module 'vue-vconsole-devtools'; 的新声明(.d.ts)文件ts(7016)

开发环境:

  • Vue 3.2.45
  • Vite 3.2.4
  • vue/cli 5.0.8

项目无法打包

需求是不跟随项目打包,直接根据环境判断通过url加载进来
我想把initPlugin挂在window,打包出文件,但是打包过程中报各种错误
image

welink、蓝信等平台开发的PC小程序中不显示devtools,但是在对应平台的手机上的相应小程序可以显示devtools

welink pc端、手机端小程序html代码:

<div id="app"></div>
    <script src="https://open-doc.welink.huaweicloud.com/docs/jsapi/2.0.6/hwh5-cloudonline.js"></script>
    <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue_plugin.js"></script>
    <script>
      var vConsole = new window.VConsole();
      const Devtools = window.vueVconsoleDevtools
      Devtools.initPlugin(vConsole);
    </script>

pc端截图:
image
手机端截图:
2bbb5dbcec6a5ccdcd81e85b70f8f05

为什么会导致在welink、蓝信这类平台中的pc端小程序devtools失效,钉钉平台没试过。希望有回复,谢谢。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.