官方地址 实现方法
安装:
npm i mind-elixir -S
引入:
示例(在VUE中使用)
</template>
<div class="outer">
<div id="map" ></div>
</div>
</template>
初始化
data(){
return{
ME:null
}
}
mounted() {
this.ME = new MindElixir({
el: "#map",
direction: MindElixir.RIGHT,
data: this.mapdata,
draggable: false,
contextMenu: false,
toolBar: true,
nodeMenu: false,
locale: 'zh_CN',
overflowHidden: false,
primaryLinkStyle: 2,
primaryNodeVerticalGap: 25,
primaryNodeHorizontalGap: 65,
allowUndo: true,
keypress: true,
});
this.ME.init();
},
赋值
methods: {
processData(data)
{
let mapdata={};
if((!data && data.length==0))
{
mapdata={"nodeData": {
"id": "d0c71fd3f8441810",
"topic": "没有相关版本信息",
"root": true}}
}
else
{
let nodeData= {
"id": "d0c71fd3f8441810",
"topic": data[0].test1,
"tags": [data[0].test2],
"expanded": true,
"root": true,"children":[] }
this.sonProcess(data,"0",nodeData)
mapdata={"nodeData": nodeData}
}
this.ME = new MindElixir({
el: "#map",
direction: MindElixir.RIGHT,
data: mapdata,
draggable: false,
contextMenu: false,
toolBar: true,
nodeMenu: false,
locale: 'zh_CN',
overflowHidden: false,
primaryLinkStyle: 2,
primaryNodeVerticalGap: 25,
primaryNodeHorizontalGap: 65,
allowUndo: true,
keypress: true
});
this.ME.init();
this.mapdata=mapdata;
this.clickNode()
},
sonProcess(data,parentId,node)
{
let sonitem= data.filter(q=>q.parentId===parentId)
sonitem.forEach(item=>{
let newson={
"topic":item.ver,
"id": item.id,
"tags": [
"ECN:" + item.ecnno ,"有效期:" + item.validate
],
children:[]
}
this.sonProcess(data,item.bomid,newson)
node.children.push(newson)
})
},
clickNode(){
this.ME.bus.addListener('selectNode', node => {
})
},
}
|