欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue2使用思維導(dǎo)圖jsmind的詳細(xì)代碼

 更新時間:2024年06月18日 11:33:23   作者:emoji111111  
jsMind是一個基于Js的思維導(dǎo)圖庫,jsMind是一個純JavaScript類庫,用于創(chuàng)建、展示和操作思維導(dǎo)圖,這篇文章主要給大家介紹了關(guān)于vue2使用思維導(dǎo)圖jsmind的詳細(xì)代碼,需要的朋友可以參考下

1、首先安裝

npm install vue-jsmind

2、在main.js 里面引入

import jm from 'vue-jsmind'
Vue.use(jm)
if (window.jsMind) {
    Vue.prototype.jsMind = window.jsMind
}

3、頁面使用

//后端返回的數(shù)據(jù)
data:[
    {rylx: "網(wǎng)格員", xgnr: "上報事件35件"}
    {rylx: "網(wǎng)格員", xgnr: "安全檢查 53 戶"}
]

最終結(jié)果

<template>
      <div id="jsmind_container_box"></div>
</template>

<script>
import rootIcon from '@/assets/images/img_ry.png'

export default {
    props: {
        data: {
            type: Array
        }
    },
    computed: {
        findParentId() {
            return function(item) {
                var parentItem = this.testData.filter(p => {
                    return item.rylx == p.topic
                })
                return parentItem[0].id
            }
        },
        uniqueItem() {
            return function(arr) {
                var uniqueArr = [...new Set(arr.map(item => item.rylx))].map(rylx =>
                    arr.find(item => item.rylx === rylx)
                )
                return uniqueArr
            }
        }
    },
    data() {
        return {
            testData: [],
            mind: {
                /* 元數(shù)據(jù),定義思維導(dǎo)圖的名稱、作者、版本等信息 */
                meta: {
                    name: '思維導(dǎo)圖',
                    author: '****',
                    version: '0.2'
                },
                /* 數(shù)據(jù)格式聲明 */
                format: 'node_array',
                /* 數(shù)據(jù)內(nèi)容 */
                data: []
            },
            styles: {
                level1: {
                    background: '#d7e2ff',
                    color: '#7581f8',
                    borderRadius: '80px',
                    fontWeight: 'bold',
                    boxShadow: 'none',
                    borderRadius: '80px',
                    fontSize: '14px',
                    border: 'none',
                    padding: '12px 20px'
                },
                level2: {
                    background: '#FFFFFF',
                    color: '#7581f8',
                    borderRadius: '80px',
                    fontWeight: '400',
                    boxShadow: 'none',
                    borderRadius: '80px',
                    border: '1px solid #7581f8',
                    fontSize: '14px',
                    color: '#7581f8',
                    padding: '8px 24px'
                }
            }
        }
    },
    mounted() {
        this.handleMind()
    },
    methods: {
        handleMind() {
            var that = this
            const root = {
                id: 'root',
                topic: '',
                'background-image': rootIcon,
                width: '200',
                height: '200',
                isroot: 'true'
            }
            var middleIndex = parseInt(that.data.length / 2)
            var newArr = this.uniqueItem(that.data)
            newArr.forEach((item, index) => {
                let query = {
                    id: String(index),
                    parentid: 'root',
                    topic: item.rylx,
                    direction: middleIndex == '1' ? 'right' : index < middleIndex ? 'left' : 'right'
                }

                that.testData.push(query)
            })
            that.data.forEach((item, index) => {
                if (item.xgnr.length) {
                    let childItem = {
                        id: index + '0',
                        parentid: this.findParentId(item),
                        topic: item.xgnr,
                        direction: 'left'
                    }
                    that.testData.push(childItem)
                }
            })

            that.testData.unshift(root)
            that.mind.data = that.testData
            that.init()
            that.applyStyles()
        },
        init() {
            var options = {
                container: 'jsmind_container_box',
                editable: false,
                view: {
                    engine: 'canvas', // 思維導(dǎo)圖各節(jié)點之間線條的繪制引擎
                    line_width: 2, // 思維導(dǎo)圖線條的粗細(xì)
                    line_color: '#D9D9D9' // 思維導(dǎo)圖線條的顏色
                },
                layout: {
                    hspace: 80, // 節(jié)點之間的水平間距
                    vspace: 10, // 節(jié)點之間的垂直間距
                    pspace: 10 // 節(jié)點與連接線之間的水平間距(用于容納節(jié)點收縮/展開控制器)
                }
            }
            this.jm = jsMind.show(options)
            this.jm.show(this.mind)
        },

        applyStyles() {
            const root = this.jm.get_root()._data.view
            root.element.style.borderRadius = '699px'
            root.element.style.backgroundSize = 'cover'
            root.element.style.boxShadow = 'none'
            this.repeatItem(this.jm.get_root().children, this.styles.level1)
        },
        repeatItem(nodes, style) {
            for (let i = 0; i < nodes.length; i++) {
                const node = nodes[i]
                node._data.view.element.style.color = style.color
                node._data.view.element.style.fontSize = style.fontSize
                node._data.view.element.style.borderRadius = style.borderRadius
                node._data.view.element.style.background = style.background
                node._data.view.element.style.fontWeight = style.fontWeight
                node._data.view.element.style.boxShadow = style.boxShadow
                node._data.view.element.style.border = style.border
                node._data.view.element.style.padding = style.padding
                if (nodes[i].children.length) {
                    this.repeatItem(nodes[i].children, this.styles.level2)
                }
            }
        }
    }
}
</script>
<style scoped>
#jsmind_container_box {
    width: 100%;
    height: 302px !important;
    border: 1px solid #d9d9d9;
}
</style>

總結(jié) 

到此這篇關(guān)于vue2使用思維導(dǎo)圖jsmind的文章就介紹到這了,更多相關(guān)vue2使用思維導(dǎo)圖jsmind內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue3源碼分析組件掛載創(chuàng)建虛擬節(jié)點

    Vue3源碼分析組件掛載創(chuàng)建虛擬節(jié)點

    這篇文章主要為大家介紹了Vue3源碼分析組件掛載創(chuàng)建虛擬節(jié)點,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-10-10
  • 如何利用vue3實現(xiàn)放大鏡效果實例詳解

    如何利用vue3實現(xiàn)放大鏡效果實例詳解

    最近有項目需要用到對圖片進行局部放大,類似淘寶商品頁的放大鏡效果,經(jīng)過一番研究功能可用,下面這篇文章主要給大家介紹了關(guān)于如何利用vue3實現(xiàn)放大鏡效果的相關(guān)資料,需要的朋友可以參考下
    2021-09-09
  • 詳解Vue進階構(gòu)造屬性

    詳解Vue進階構(gòu)造屬性

    這篇文章主要介紹了Vue進階構(gòu)造屬性,從4個方面來進行講解:Directive、Mixin 混入、Extends 繼承、provide 和 inject,感興趣的小伙伴們,趕快來看一下
    2021-05-05
  • vue使用exif獲取圖片旋轉(zhuǎn),壓縮的示例代碼

    vue使用exif獲取圖片旋轉(zhuǎn),壓縮的示例代碼

    這篇文章主要介紹了vue使用exif獲取圖片旋轉(zhuǎn),壓縮的示例代碼,幫助大家更好的利用python處理圖片,感興趣的朋友可以了解下
    2020-12-12
  • 利用Vue3實現(xiàn)一個可以用js調(diào)用的組件

    利用Vue3實現(xiàn)一個可以用js調(diào)用的組件

    最近遇到個功能要求,想要在全局中調(diào)用組件,而且要在某些js文件內(nèi)調(diào)用,所以這篇文章主要給大家介紹了關(guān)于如何利用Vue3實現(xiàn)一個可以用js調(diào)用的組件的相關(guān)資料,需要的朋友可以參考下
    2021-08-08
  • Vue數(shù)據(jù)雙向綁定的實現(xiàn)方式講解

    Vue數(shù)據(jù)雙向綁定的實現(xiàn)方式講解

    Vue數(shù)據(jù)雙向綁定原理:Vue內(nèi)部通過Object.defineProperty方法屬性攔截的方式,把data對象里每個數(shù)據(jù)的讀寫轉(zhuǎn)化成getter/setter,當(dāng)數(shù)據(jù)變化時通知視圖更新
    2022-08-08
  • nuxt踩坑之Vuex狀態(tài)樹的模塊方式使用詳解

    nuxt踩坑之Vuex狀態(tài)樹的模塊方式使用詳解

    這篇文章主要介紹了nuxt踩坑之Vuex狀態(tài)樹的模塊方式使用詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • vue使用prop可以渲染但是打印臺報錯的解決方式

    vue使用prop可以渲染但是打印臺報錯的解決方式

    今天小編就為大家分享一篇vue使用prop可以渲染但是打印臺報錯的解決方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • vue-quill-editor插入圖片路徑太長問題解決方法

    vue-quill-editor插入圖片路徑太長問題解決方法

    這篇文章主要介紹了vue-quill-editor插入圖片路徑太長問題解決方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • 關(guān)于axios的proxy代理配置解析

    關(guān)于axios的proxy代理配置解析

    這篇文章主要介紹了關(guān)于axios的proxy代理配置解析,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-07-07

最新評論