思維導(dǎo)圖插件jsMind的詳細(xì)使用指南
1、下載jsMind
npm install jsMind --s
2、在需要使用的頁面 引入css樣式和js方法
import "jsmind/style/jsmind.css"; import jsMind from "jsmind/js-legacy/jsmind.js";
3、初始化jsMind
export default { data() { return { mind: { /* 元數(shù)據(jù),定義思維導(dǎo)圖的名稱、作者、版本等信息 */ meta: { name: "思維導(dǎo)圖", author: "", version: "0.2", }, /* 數(shù)據(jù)格式聲明 */ format: "node_tree", /* 數(shù)據(jù)內(nèi)容 */ data: { id: "root", topic: "jsMind", children: [ { id: "easy", // [必選] ID, 所有節(jié)點(diǎn)的ID不應(yīng)有重復(fù),否則ID重復(fù)的結(jié)節(jié)將被忽略 topic: "Easy", // [必選] 節(jié)點(diǎn)上顯示的內(nèi)容 direction: "right", // [可選] 節(jié)點(diǎn)的方向,此數(shù)據(jù)僅在第一層節(jié)點(diǎn)上有效,目前僅支持 left 和 right 兩種,默認(rèn)為 right // expanded: false, // [可選] 該節(jié)點(diǎn)是否是展開狀態(tài),默認(rèn)為 true children: [ { id: "easy8", topic: "Easy to show", children: [ { id: "open7", topic: "on GitHub" }, { id: "easy7", topic: "Easy to embed" }, ], }, { id: "easy2", topic: "Easy to edit" }, { id: "easy3", topic: "Easy to store" }, { id: "easy4", topic: "Easy to embed" }, ], }, { id: "open", topic: "Open Source", direction: "right", // expanded: false, children: [ { id: "open1", topic: "on GitHub" }, { id: "open2", topic: "BSD License" }, ], }, { id: "powerful", topic: "Powerful", direction: "right", // expanded: false, children: [ { id: "powerful1", topic: "Base on Javascript" }, { id: "powerful2", topic: "Base on HTML5" }, { id: "powerful3", topic: "Depends on you" }, ], }, { id: "other", topic: "test node", direction: "right", // expanded: false, children: [ { id: "other1", topic: "I'm from local variable" }, { id: "other2", topic: "I can do everything" }, ], }, ], }, }, options: { container: "jsmind_container", // [必選] 容器的ID editable: true, // [可選] 是否啟用編輯 theme: "primary", // [可選] 主題 view: { engine: "canvas", // 思維導(dǎo)圖各節(jié)點(diǎn)之間線條的繪制引擎 hmargin: 20, // 思維導(dǎo)圖距容器外框的最小水平距離 vmargin: 20, // 思維導(dǎo)圖距容器外框的最小垂直距離 line_width: 2, // 思維導(dǎo)圖線條的粗細(xì) line_color: "#ddd", // 思維導(dǎo)圖線條的顏色 hide_scrollbars_when_draggable: true, }, layout: { hspace: 100, // 節(jié)點(diǎn)之間的水平間距 vspace: 20, // 節(jié)點(diǎn)之間的垂直間距 pspace: 20, // 節(jié)點(diǎn)與連接線之間的水平間距(用于容納節(jié)點(diǎn)收縮/展開控制器) }, shortcut: { enable: false, // 是否啟用快捷鍵 默認(rèn)為true }, // editableDrag:true, // get_selected_node:function(val){ // this.selectedNode=val // } }, jm: "", selectedNode: "", newNodeId: 1, }; }, mounted() { // 初始化 this.jm = new jsMind(this.options); //渲染canvas this.jm.show(this.mind); }, };
4、頁面綁定dom
<div id="jsmind_container"></div>
5、效果圖
6、內(nèi)置方法
獲取節(jié)點(diǎn)
獲取根節(jié)點(diǎn) : this.jm.get_root()
根據(jù) id 查找節(jié)點(diǎn) : this.jm.get_node(nodeid)
獲取選中的節(jié)點(diǎn) : this.jm.get_selected_node()
查找相鄰的上一個節(jié)點(diǎn) : this.jm.find_node_before(node|nodeid)
查找相鄰的下一個節(jié)點(diǎn) : this.jm.find_node_after(node|nodeid)
操作節(jié)點(diǎn)
選中節(jié)點(diǎn) : this.jm.select_node(node)
收起子節(jié)點(diǎn) : this.jm.collapse_node(node|nodeid)
展開子節(jié)點(diǎn) : this.jm.expand_node(node|nodeid)
收起或展開子節(jié)點(diǎn) :this.jm.toggle_node(node|nodeid)
方法可自動展開或收起子節(jié)點(diǎn)。
展開全部子節(jié)點(diǎn) : this.jm.expand_all()
展開至指定層級 : this.jm.expand_to_depth(depth)
移動節(jié)點(diǎn) : this.jm.move_node(node|nodeid,beforeid)
啟用編輯 : this.jm.enable_edit()
禁止編輯 : this.jm.disable_edit()
調(diào)整節(jié)點(diǎn)為編輯狀態(tài) : this.jm.begin_edit(node|nodeid)
調(diào)整節(jié)點(diǎn)為只讀狀態(tài) : this.jm.end_edit(node|nodeid)
加減節(jié)點(diǎn)
添加節(jié)點(diǎn) : this.jm.add_node(parent_node, nodeid, topic, data)
在指定位置前插入節(jié)點(diǎn) : this.jm.insert_node_before(node_before, nodeid, topic)
在指定位置后插入節(jié)點(diǎn) : this.jm.insert_node_after(node_after, nodeid, topic)
刪除節(jié)點(diǎn)及其子節(jié)點(diǎn) : this.jm.remove_node(node|nodeid)
更新節(jié)點(diǎn)topic顯示內(nèi)容 : this.jm.update_node(nodeid, topic)
獲取數(shù)據(jù)
獲取元數(shù)據(jù) :this.jm.get_meta()
。
獲取指定格式的思維導(dǎo)圖數(shù)據(jù) : this.jm.get_data(data_format)
設(shè)置樣式
設(shè)置主題 : this.jm.set_theme(theme)
設(shè)置背景色/前景色 : this.jm.set_node_color(nodeid, bgcolor, fgcolor)
設(shè)置字體 : this.jm.set_node_font_style(nodeid, size, weight, style)
設(shè)置背景圖片 : this.jm.set_node_background_image(nodeid, image, width, height)
其他操作
清除節(jié)點(diǎn)的選中 : this.jm.select_clear()
。
判斷節(jié)點(diǎn)是否可見 : this.jm.is_node_visible(node)
總結(jié)
到此這篇關(guān)于思維導(dǎo)圖插件jsMind的詳細(xì)使用指南的文章就介紹到這了,更多相關(guān)思維導(dǎo)圖插件jsMind內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
深入理解JS中的微任務(wù)和宏任務(wù)的執(zhí)行順序及應(yīng)用場景
JavaScript中的任務(wù)分為宏任務(wù)和微任務(wù),它們的執(zhí)行順序會影響代碼的執(zhí)行結(jié)果。了解它們的機(jī)制可以幫助我們更好地理解事件循環(huán)和異步編程,避免出現(xiàn)一些意想不到的錯誤2023-05-05layui自己添加圖片按鈕并點(diǎn)擊跳轉(zhuǎn)頁面的例子
今天小編就為大家分享一篇layui自己添加圖片按鈕并點(diǎn)擊跳轉(zhuǎn)頁面的例子,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09JS實(shí)現(xiàn)的DOM插入節(jié)點(diǎn)操作示例
這篇文章主要介紹了JS實(shí)現(xiàn)的DOM插入節(jié)點(diǎn)操作,結(jié)合實(shí)例形式分析了javascript針對頁面dom元素動態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-04-04小程序獲取當(dāng)前位置加搜索附近熱門小區(qū)及商區(qū)的方法
這篇文章主要介紹了小程序獲取當(dāng)前位置加搜索附近熱門小區(qū)及商區(qū)的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-04-04自用js開發(fā)框架小成 學(xué)習(xí)js的朋友可以看看
前段時(shí)間項(xiàng)目需要用到j(luò)s樹,找了好多都不符合項(xiàng)目需求,后來發(fā)現(xiàn)了梅花雪樹和js框架,類似C#名稱空間的用法讓我眼前一亮,遂拿來主義,讀了幾遍代碼后就開工了(我是個急性子呵呵),完成了大部分,最近才找出來測試了下。2010-11-11用JavaScript和注冊表腳本實(shí)現(xiàn)右鍵收藏Web頁選中文本
用JavaScript和注冊表腳本實(shí)現(xiàn)右鍵收藏Web頁選中文本...2007-01-01