vue-orgchart做组织架构图

时间:2022-07-24
本文章向大家介绍vue-orgchart做组织架构图,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Vue-orgchart链接地址

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ERP树形组织图</title>
    <link rel="stylesheet" href="https://cdn.suoluomei.com/common/js2.0/npm/vue-orgchart/dist/style.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<style>
    #chart-container {
        overflow: inherit !important;
    }

    .orgchart .node .title {
        font-size: 20px;
        padding: 20px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 5px;
        line-height: 0;
        flex-direction: row-reverse;
        background: lightseagreen;
    }

    .orgchart .node .title .symbol {
        float: none;
        margin-top: 0;
        margin-right: 10px;
    }

    .orgchart .node {
        width: auto;
    }

    .oc-export-btn {
        bottom: 88%;
    }
</style>

<body>
    <div id="vue">
        <vo-basic :data="chartData" :pan="true" :zoom="true" :export-button="true" export-button-name="导出"
            :draggable="true" :toggle-siblings-resp="true" parent-node-symbol="fa-users"></vo-basic>
    </div>
</body>
<script src="http://cdn.suoluomei.com/common/js2.0/vue/v2.5.16/vue.js"></script>
<script src="https://cdn.suoluomei.com/common/js2.0/npm/vue-orgchart/dist/vue-orgchart.min.js"></script>
<script src="https://cdn.suoluomei.com/common/js2.0/html2canvas/1.0/html2canvas.min.js"></script>
<script type="text/javascript">
    new Vue({
        el: '#vue',
        data: {
        },
        created() {
            this.chartData = {
                name: '组织架构图',
                children: [
                    {
                        name: '超能者',
                        children: [
                            {
                                name: '总监',
                                children: [
                                    {
                                        name: '主管',
                                        children: [
                                            { name: '前端客服' },
                                            { name: '推广员' }
                                        ]
                                    },
                                ]
                            },
                        ]
                    },
                    {
                        name: '董事长',
                        children: [
                            {
                                name: '总经办',
                                children: [
                                    { name: '外部访问组' }
                                ]
                            },
                        ]
                    },
                ]
            }
        }
    })
</script>
</html>

如果需要做动态渲染,比如点击某一项显示对应的结构图要重新对组件进行初始化

获取dom节点,重新.innerHTML(<div>...</div>), //要浏览器解析出来的div