过早客
  • 首页
  • 节点
  • 成员
  • 广告投放
  • 登录
  • 注册

基于Vue实现动态组织结构图

IT技术 • tower1229 • 发表于 6 年前 • 最后回复来自 chenley • 6 年前

vue-tree-chart

npm [license]()

Vue2树形图组件

首页:https://github.com/tower1229/Vue-Tree-Chart

logo

安装

npm i vue-tree-chart --save

使用

in template:

<TreeChart :json="treeData" />

in script:

import TreeChart from "vue-tree-chart";

export default {
    components: {
        TreeChart
    },
    data() {
        return {
            treeData: {
                ...
            }
        }
    }
    ...

属性

json

组件数据,支持字段:

- name[String] 节点名称
- image_url[String] 节点图片
- children[Array] 节点后代
- mate[Object] 节点配偶

示例:

{
    name: 'root',
    image_url: "https://static.refined-x.com/avat.jpg",
    children: [
      {
        name: 'children1',
        image_url: "https://static.refined-x.com/avat1.jpg"
      },
      {
        name: 'children2',
        image_url: "https://static.refined-x.com/avat2.jpg",
        mate: {
          name: 'mate',
          image_url: "https://static.refined-x.com/avat3.jpg"
        },
        children: [
          {
            name: 'grandchild',
            image_url: "https://static.refined-x.com/avat.jpg"
          },
          {
            name: 'grandchild2',
            image_url: "https://static.refined-x.com/avat1.jpg"
          },
          {
            name: 'grandchild3',
            image_url: "https://static.refined-x.com/avat2.jpg"
          }
        ]
      },
      {
        name: 'children3',
        image_url: "https://static.refined-x.com/avat.jpg"
      }
    ]
  }

事件

click-node

点击节点触发,接收当前节点数据为参数

演示

npm run serve

构建

npm run build-bundle

Copyright (c) 2017-present, 前端路上

加入收藏 新浪微博 分享到微信 ❤赞 6329 次点击 0 人赞 1 人收藏

打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮

共收到1条回复
chenley 6 年前 #1 赞 0

消灭0️⃣回复~~~~!

请绑定手机号后,再发言,点击此处
Guozaoke.com—源自武汉的高端交流分享社区
相关主题
最近时间少了, 隔了这么久, 才做了一个网站
做了一款摸鱼软件,有人要试用吗?
有搞嵌入式硬件的吗?
搞了个AI 生图的网站,不需要登录,永久免费
社友们,你们是怎么入编程这行的?
计算机相关5000本电子书PDF分享
求推荐一个AI智能体客服
关于团队开发习惯
cursor这么强大,web前端是不是要淘汰了
求助,越来越穷了,有没有老板给一些php开发单子做呀!

过早客微信公众号:guozaoke • 过早客新浪微博:@过早客 • 广告投放合作微信:fullygroup50 鄂ICP备2021016276号-2 • 鄂公网安备42018502001446号