|
| 1 | +<p align="center"> |
| 2 | + <img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/bg.png" /> |
| 3 | +</p> |
| 4 | +<h1 align="center"> |
| 5 | +Vue DevTools <sup>预览</sup> |
| 6 | +</h1> |
| 7 | + |
| 8 | +<p align="center"> |
| 9 | +<a href="./README.md">English</a> | 简体中文 |
| 10 | +</p> |
| 11 | + |
| 12 | +<p align="center"> |
| 13 | + <a href="https://www.npmjs.com/package/vite-plugin-vue-devtools" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/vite-plugin-vue-devtools" alt="NPM Version" /></a> |
| 14 | + <a href="https://www.npmjs.com/package/vite-plugin-vue-devtools" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/dt/vite-plugin-vue-devtools" alt="NPM Downloads" /></a> |
| 15 | + <a href="https://github.com/webfansplz/vite-plugin-vue-devtools/blob/main/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/webfansplz/vite-plugin-vue-devtools" alt="License" /></a> |
| 16 | +</p> |
| 17 | + |
| 18 | +<p align="center"> |
| 19 | + <a href="https://github.com/webfansplz/vite-plugin-vue-devtools/discussions/1">💡 想法 & 建议</a> | |
| 20 | + <a href="https://github.com/webfansplz/vite-plugin-vue-devtools/discussions/2">🗺️ 项目路线图</a> |
| 21 | +</p> |
| 22 | + |
| 23 | +<p align="center"> |
| 24 | +<a href="https://stackblitz.com/edit/vitejs-vite-oxbwzk?file=vite.config.ts&view=preview"><img src="https://developer.stackblitz.com/img/open_in_stackblitz.svg" alt=""></a> |
| 25 | +</p> |
| 26 | + |
| 27 | + |
| 28 | +## 📖 介绍 |
| 29 | + |
| 30 | +`vite-plugin-vue-devtools` 是一个旨在增强 Vue 开发者体验的Vite插件。 |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +## 🎉 特性 |
| 35 | + |
| 36 | +### Pages |
| 37 | + |
| 38 | +`Pages` 选项卡显示您当前的页面路由并提供快速导航的方法。对于动态路由,它还提供了一个表单来交互式地填写每个参数。您还可以使用文本框来测试每个路由的匹配情况。 |
| 39 | + |
| 40 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/pages.png" /> |
| 41 | + |
| 42 | + |
| 43 | +### Components |
| 44 | + |
| 45 | +`Components` 选项卡显示您应用程序的所有组件树,您还可以选择它们来查看组件的详细信息(例如数据、属性)。 |
| 46 | + |
| 47 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/components.png" /> |
| 48 | + |
| 49 | +### Assets |
| 50 | + |
| 51 | +`Assets` 选项卡显示所有静态资源及其信息,您可以在浏览器中打开或下载它。 |
| 52 | + |
| 53 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/assets.png" /> |
| 54 | + |
| 55 | +### Timeline |
| 56 | + |
| 57 | +`Timeline` 选项卡包含三个类别:性能、路由导航和 Pinia,您可以在它们之间切换以查看状态变化和时间线。 |
| 58 | + |
| 59 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/timeline.png" /> |
| 60 | + |
| 61 | +### Routes |
| 62 | + |
| 63 | +`Routes` 选项卡是与 [Vue Router](https://github.com/vuejs/router) 集成的功能,允许您查看注册的路由及其详细信息。 |
| 64 | + |
| 65 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/routes.png" /> |
| 66 | + |
| 67 | +### Pinia |
| 68 | + |
| 69 | +`Pinia` 选项卡是与 [Pinia](https://github.com/vuejs/pinia) 集成的功能,允许您查看注册的模块及其详细信息。 |
| 70 | + |
| 71 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/pinia.png" /> |
| 72 | + |
| 73 | +### Graph |
| 74 | + |
| 75 | +`Graph` 选项卡提供了显示组件依赖关系的视图。 |
| 76 | + |
| 77 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/graph.png" /> |
| 78 | + |
| 79 | +### Inspect |
| 80 | + |
| 81 | +`Inspect` 公开 [vite-plugin-inspect](https://github.com/antfu/vite-plugin-inspect) 集成,允许您检查 Vite 的转换步骤,了解每个插件如何改变您的代码并发现潜在问题可能会有所帮助。 |
| 82 | + |
| 83 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/inspect.png" /> |
| 84 | + |
| 85 | +### Inspector |
| 86 | + |
| 87 | +您还可以使用 `Inspector` 功能来检查 `DOM` 树并查看哪个组件正在渲染它,单击可转到特定行的编辑器,使更改变得更加容易,而无需彻底了解项目结构。 (该功能基于 [vite-plugin-vue-inspector](https://github.com/webfansplz/vite-plugin-vue-inspector)) |
| 88 | + |
| 89 | +<img src="https://github.com/webfansplz/vite-plugin-vue-devtools/raw/main/screenshots/inspector.png" height=450 /> |
| 90 | + |
| 91 | +## 📦 安装 |
| 92 | + |
| 93 | +``` |
| 94 | +
|
| 95 | +# vite-plugin-vue-devtools |
| 96 | +
|
| 97 | +pnpm install vite-plugin-vue-devtools -D |
| 98 | +
|
| 99 | +``` |
| 100 | + |
| 101 | +## 🦄 示例 |
| 102 | + |
| 103 | +### Vite 配置 |
| 104 | + |
| 105 | +```ts |
| 106 | +import { defineConfig } from 'vite' |
| 107 | +import VueDevTools from 'vite-plugin-vue-devtools' |
| 108 | + |
| 109 | +export default defineConfig({ |
| 110 | + plugins: [ |
| 111 | + VueDevTools(), |
| 112 | + vue(), |
| 113 | + ], |
| 114 | +}) |
| 115 | +``` |
| 116 | + |
| 117 | +### 选项 |
| 118 | + |
| 119 | +```ts |
| 120 | +interface VitePluginVueDevToolsOptions { |
| 121 | + /** |
| 122 | + * append an import to the module id ending with `appendTo` instead of adding a script into body |
| 123 | + * useful for projects that do not use html file as an entry |
| 124 | + * |
| 125 | + * WARNING: only set this if you know exactly what it does. |
| 126 | + */ |
| 127 | + appendTo?: string | RegExp |
| 128 | +} |
| 129 | +``` |
| 130 | + |
| 131 | +## 💡 注意 |
| 132 | + |
| 133 | +- 仅在 `开发模式` 下可用。 |
| 134 | +- 仅支持 `Vue3.0+` 。 |
| 135 | +- 仅支持单实例 `Vue` 应用程序。 |
| 136 | +- 不支持 `SSR` (如果您使用 `Nuxt` ,请使用 [nuxt/devtools](https://github.com/nuxt/devtools))。 |
| 137 | +- 该插件遵循 `Vue` 的 `DevTools` 配置,因此如果您配置了 `hide` 选项,它也将应用于该插件。例如 |
| 138 | + |
| 139 | + ```js |
| 140 | + // This Vue instance will be ignored by the plugin. |
| 141 | + createApp({ |
| 142 | + render: () => h(App), |
| 143 | + devtools: { |
| 144 | + hide: true, |
| 145 | + }, |
| 146 | + }) |
| 147 | + ``` |
| 148 | + |
| 149 | +## 📖 博客 |
| 150 | + |
| 151 | +- [介绍 Vue DevTools (Vite 插件)](https://gist.github.com/webfansplz/bc90a773a0dd474a34e043ab2d2a37a4) |
| 152 | + |
| 153 | +## 🌸 致谢 |
| 154 | + |
| 155 | +- 该项目深受 [nuxt/devtools](https://github.com/nuxt/devtools) 的启发,感谢 `Anthony Fu` 和 `Nuxt` 团队的出色工作 |
| 156 | + |
| 157 | +- [vuejs/devtools](https://github.com/vuejs/devtools) |
| 158 | + |
| 159 | + |
| 160 | +## 👨💻 贡献者 |
| 161 | + |
| 162 | +<a href="https://github.com/webfansplz/vite-plugin-vue-devtools/graphs/contributors"> |
| 163 | + <img src="https://contrib.rocks/image?repo=webfansplz/vite-plugin-vue-devtools" /> |
| 164 | +</a> |
| 165 | + |
| 166 | +## 📄 License |
| 167 | + |
| 168 | +[MIT LICENSE](./LICENSE) |
| 169 | + |
0 commit comments