前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >vue-orgchart做组织架构图

vue-orgchart做组织架构图

作者头像
明知山
发布2020-09-03 10:45:59
2.2K0
发布2020-09-03 10:45:59
举报
文章被收录于专栏:前端开发随笔前端开发随笔

Vue-orgchart链接地址

在这里插入图片描述
在这里插入图片描述
代码语言:javascript
复制
<!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>

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

代码语言:javascript
复制
获取dom节点,重新.innerHTML(<div>...</div>), //要浏览器解析出来的div
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-11-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档