安装
npm install @hellowuxin/mindmap
or
yarn add @hellowuxin/mindmap
vue中使用
<template>
<div class="nav">
<mindmap
height="500"
width="100%"
nodeClick
zoomable
showNodeAdd
v-model="data"
></mindmap>
</div>
</template>
<script>
import mindmap from "@hellowuxin/mindmap";
export default {
components: { mindmap },
data() {
return {
data: [
{
name: "思维导图",
children: [
{
name: "标题一",
children: [
{ name: "内容一" },
{ name: "内容二" }
],
},
{
name: "标题二",
_children: [{ name: "折叠节点" }],
},
{
name: "标题三",
left: true,
children: [
{ name: "内容一" },
{ name: "内容二" }
],
},
],
},
],
};
},
};
</script>
API
Name | Type | Default | Description |
---|
v-model | Array | undefined | 设置思维导图数据 |
width | Number | 100% | 设置组件宽度 |
height | Number | undefined | 设置组件高度 |
xSpacing | Number | 80 | 设置节点横向间隔 |
ySpacing | Number | 20 | 设置节点纵向间隔 |
strokeWidth | Number | 4 | 设置连线的宽度 |
draggable | Boolean | true | 设置节点是否可拖拽 |
gps | Boolean | true | 是否显示居中按钮 |
fitView | Boolean | true | 是否显示缩放按钮 |
showNodeAdd | Boolean | true | 是否显示添加节点按钮 |
keyboard | Boolean | true | 是否响应键盘事件 |
contextMenu | Boolean | true | 是否响应右键菜单 |
nodeClick | Boolean | true | 设置节点是否可点击、编辑 |
zoomable | Boolean | true | 是否可缩放、拖移 |
showUndo | Boolean | true | 是否显示撤销重做按钮 |