1.0.9 • Published 9 months ago

directory-box v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

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

一、问题的描述

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

二 、先看效果图

在这里插入图片描述

三、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" }],
      },
    ],
  },
];
参数说明类型默认值版本
treeDatatreeNodes 数据,如果设置则不需要手动构造 TreeNode 节点(key 在整个树范围内唯一)TreeNode[]-
paneSize目录的宽度number250-
title目录标题名称string目录-
height目录高度number300-

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

1.0.9

9 months ago

1.0.8

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago