npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ds-vue-quick-location

v1.0.2

Published

Vue组件快速定位助手 For Vue2.x

Downloads

19

Readme

组件定位助手 For Vue2.x

简介

ds-vue-quick-location 是一个方便开发者调试 Vue2.x 项目中组件树结构的工具。通过点击页面元素,它会在控制台中显示对应的 Vue 组件及其父子关系,并生成便于快速定位到代码文件的链接。

安装

使用 npm 安装:

npm install ds-vue-quick-location --save

引入

// <!-- main.js -->
import 'ds-vue-quick-location';

配置

为了让组件定位助手正常运行,您需要在 webpack 或 vue.config.js 中定义 PROJECT_PATH,以告知工具您的项目根路径。

配置方法

在 vue.config.js 中添加以下代码:

const webpack = require('webpack');

module.exports = {
    configureWebpack: config => {
        config.plugins.push(
            new webpack.DefinePlugin({
                PROJECT_PATH: JSON.stringify(__dirname) // 项目根路径
            })
        );
    }
};

使用方法

1. 运行项目

在开发模式下启动您的 Vue 项目。

2. 点击页面任意元素

在浏览器页面中,点击任意元素。组件定位助手会清空控制台,并输出点击组件的相关信息。

3. 查看控制台输出

控制台中会显示:

  • 组件树结构

    包括点击的组件及其父子关系。

  • 组件名与文件路径

    组件名和文件路径会生成 vscode:// 格式的链接,点击后可直接在 VS Code 中打开对应的文件。

控制台输出示例

点击某个组件后的控制台输出:

组件定位助手:
|--RootComponent (vscode://file/path-to-project/src/components/RootComponent.vue)
|----ParentComponent (vscode://file/path-to-project/src/components/ParentComponent.vue)
|------ClickedComponent (vscode://file/path-to-project/src/components/ClickedComponent.vue)

输出说明

• RootComponent 表示组件树的根组件。

• ParentComponent 表示点击组件的父级组件。

• ClickedComponent 被点击的组件,使用绿色高亮显示。

可选功能

清除日志功能

工具默认会在每次点击页面元素时清空控制台记录。您可以通过 localStorage 配置控制此行为:

localStorage.setItem('CLEAR_LOG_CLICKED', 0); // 禁用清除控制台
localStorage.setItem('CLEAR_LOG_CLICKED', 1); // 启用清除控制台(默认)

注意事项

1. 组件名和文件路径

如果组件未设置 name 属性或文件路径未能正确解析,将显示为 AnonymousComponent 或 Unknown File。

2. 路径生成

确保 PROJECT_PATH 的值与项目根路径一致,避免生成的 vscode:// 链接失效。

支持

如果您在使用中遇到问题,欢迎通过 Issue 提交反馈!