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 🙏

© 2026 – Pkg Stats / Ryan Hefner

directory-box

v1.0.9

Published

一个支持目录树形结构,自定义目录高亮的锚点计算位移,且支持选中该目录后锚点对应的内容。这里只提供左边的组件思路,右边展示对应的内容最好自己自定义组件控制更为灵活,会提供思路。

Readme

如果可以实现记得给个星星,谢谢老铁~

一、问题的描述

一个支持目录树形结构,自定义目录高亮的锚点计算位移,且支持选中该目录后锚点对应的内容。这里只提供左边的组件思路,右边展示对应的内容最好自己自定义组件控制更为灵活,会提供思路。

二 、先看效果图

在这里插入图片描述

三、npm i directory-boxyarn add directory-box 到自己项目

首先在自己的项目中的main.ts 文件中引入,如:

import { createApp } from "vue";
import DirectoryBox from "directory-box";
import App from "./App.vue";
import "../node_modules/directory-box/directory-box.css";

const app = createApp(App);
app.use(DirectoryBox);
app.mount("#app");

然后再自己的业务组件中直接引用

<div class="main">
  <directory-box :treeData="treeData"></directory-box>
  <div id="contentMain" class="contentMain">
    此处是右边映射的锚点,注意给每一个段落设置一个id,如:
    <div :id="item.id"></div>
  </div>
</div>

PS: 此处是右边映射的锚点,注意给每一个段落设置一个 id ,这个 id 对应左侧目录结构中的 key 值。

PS: 这里的 treeData 是数据源。数据结果为:

const treeData = [
  {
    title: "parent 1",
    key: "0-0",
    children: [
      {
        title: "parent 1-0",
        key: "0-0-0",
        disabled: true,
        children: [
          { title: "leaf", key: "0-0-0-0", disableCheckbox: true },
          { title: "leaf", key: "0-0-0-1" },
        ],
      },
      {
        title: "parent 1-1",
        key: "0-0-1",
        children: [{ key: "0-0-1-0", title: "sss" }],
      },
    ],
  },
];

| 参数 | 说明 | 类型 | 默认值 | 版本 | | :------- | :------------------------------------------------------------------------------- | :--------- | :----- | :--- | | treeData | treeNodes 数据,如果设置则不需要手动构造 TreeNode 节点(key 在整个树范围内唯一) | TreeNode[] | - | | | paneSize | 目录的宽度 | number | 250 | - | | title | 目录标题名称 | string | 目录 | - | | height | 目录高度 | number | 300 | - |

收工!谢谢老铁们的点赞收藏~