vue3.0 树形数据插件

官网:vue3-tree-org

安装

推荐使用npm安装,它能更好地和webpackopen in new window打包工具配合使用。而且可以更好的和 es6配合使用。并且支持按需引入

npm i vue3-tree-org -S
# or 
yarn add vue3-tree-org

#引入

在 main.js 中写入以下内容:

import { createApp } from 'vue'
import vue3TreeOrg from 'vue3-tree-org';
import "vue3-tree-org/lib/vue3-tree-org.css";

const app = createApp(App)

app.use(vue3TreeOrg)
app.mount('#app')

<template>
    <vue3-tree-org style="background: none;color: #FFFFFF" :data="data" :node-draggable="false" :zoom="0.5"
                   :props="{ id: 'id', label: 'label', children: 'children' }" center :horizontal="horizontal"
                   :disabled="disaled" :collapsable="collapsable" :label-style="style" :only-one-node="onlyOneNode"
                   :toolBar="{ scale: false, restore: false, expand: false, zoom: false, fullscreen: false, center: false }"

    />
</template>
<script setup>
import {ref, watch,defineProps,} from 'vue'

const props = defineProps({current:undefined})

const data = ref( {
    id: 0,
    label: "北投大厦",
    children: [
      {
        id: 2,
        label: "研发部",
        children: [
          {
            id: 5,
            label: "前端"
          },
          {
            id: 6,
            label: "后端"
          },
        ]
      },
      {
        id: 2,
        label: "产品部",
        children: [
          {
            id: 5,
            label: "产品"
          },
        ]
      },
      {
        id: 3,
        label: "销售部",
        children: [
          {
            id: 7,
            label: "销售"
          },
          {
            id: 8,
            label: "销售"
          }
        ]
      },
    ]
  })
watch(()=>props.current, (newValue) => {
    //数据更新
    Object.assign(data.value,  props.current);
})
const horizontal = ref(false)
const collapsable = ref(false)
const onlyOneNode = ref(false)
const disaled = ref(false)
const style = ref({
    background: "none",
    color: "#fff",
})
const queryParams = ref({
    pageNum: 1,
    pageSize: 10,
    deptName: undefined,
    status: undefined
})
</script>
<style lang="scss">

.zm-tree-org .tree-org-node__text {
  //border: 1px dashed #1C95D3;
  padding: 8px 20px;
  border-radius: 5px;
  background: rgba(7, 41, 64, .6);
  //box-shadow: inset 5px 0px 8px 0px #007FE0;  表示阴影的水平偏移、垂直偏移、模糊半径和颜色
  box-shadow: inset 0px 4px 10px 0 #0c4f7b
}

.tree-org-node:not(:first-child):before, .tree-org-node:not(:last-child):after {
  border-top: 0.0625rem solid #1C95D3 !important;
}

.tree-org-node:after {
  left: 50%;
  //border-left: 0.0625rem solid #1C95D3!important;
}

.tree-org-node__children:before {
  border-left: 0.0625rem solid #1C95D3 !important;
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

.. ..

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值