VVLL.net

vue3-mindmap

日期:2024-08-22 09:58:31

vue3-mindmap https://github.com/hellowuxin/vue3-mindmap

https://github.com/hellowuxin/vue3-mindmap

npmbuildcoveralls

Mindmap component for Vue3 inspired by MindNode

live demo / 演示页面

Install

npm install vue3-mindmap

PROPS

NameTypeDefaultDescription
v-modelDataundefined设置思维导图数据
x-gapNumber84设置节点横向间隔
y-gapNumber18设置节点纵向间隔
branchNumber4设置连线的宽度
scale-extentNumber, Number0.1, 0.8设置缩放范围
timetravelBooleanfalse是否显示撤销重做按钮
dragBooleanfalse设置节点是否可拖拽
zoomBooleanfalse是否可缩放、拖移
editBooleanfalse是否可编辑
center-btnBooleanfalse是否显示居中按钮
fit-btnBooleanfalse是否显示缩放按钮
add-node-btnBooleanfalse是否显示添加节点按钮
download-btnBooleanfalse是否显示下载按钮
sharp-cornerBooleanfalse设置分支为圆角或直角
ctmBooleanfalse是否响应右键菜单
locale'zh' | 'en' | 'ptBR''zh'i18n

Example

<template>
  <mindmap v-model="data"></mindmap>
</template>

<script>
  import mindmap from 'vue3-mindmap'
  import 'vue3-mindmap/dist/style.css'

  export default defineComponent({
    components: { mindmap },
    setup () => {
      const data = [{
        "name":"如何学习D3",
        "children": [
          {
            "name":"预备知识",
            "children": [
              { "name":"HTML & CSS" },
              { "name":"JavaScript" },
              ...
            ]
          },
          {
            "name":"安装",
            "collapse": true,
            "children": [ { "name": "折叠节点" } ]
          },
          { "name":"进阶", "left": true },
          ...
        ]
      }]

      return { data }
    }
  })
</script>

注意

  • 当 xGap 小于一定数值,父节点的 trigger 由于添加按钮的存在可能遮挡住子节点的 trigger,无法响应子节点的点击

待解决

  • 直角分支 radius

Todo

  • 多选节点
  • 多主节点
  • 更多节点样式

标签