vue横向树结构_vue树形结构样式和功能

本文介绍了如何在Vue中创建一个横向展示的树形结构,包括展开收起节点的功能和当前选中节点的高亮显示。通过使用`v-show`控制节点的显示状态,以及事件监听来处理节点操作。同时还提供了相应的CSS样式来美化树形结构,如边框、颜色等。
摘要由CSDN通过智能技术生成
  • {{ !item.show ? '-' : '+' }}

    {{ item.name }}

    v-show="!item.show"

    :model="item.children"

    :current="current"

    @change="changeCurrent">

export default {

name: 'EwTree',

props: {

model: {

type: Array,

default() {

return []

}

},

current: {

type: String,

default: ''

}

},

methods: {

toggle(item) {

console.log(item)

var idx = this.model.indexOf(item)

this.$set(this.model[idx], 'show', !item.show)

},

clickSize(id) {

console.log(1, id)

this.$emit('change', id)

},

changeCurrent(id) {

this.clickSize(id)

}

},

mounted() {

}

}

*{

box-sizing: border-box;

margin: 0;padding: 0;

}

*:before,*:after{

box-sizing: border-box;

}

ul,

li {

list-style: none;

}

.current{

color: #e9c309 !important

}

.l_tree_container {

width: 100%;

height: 100%;

box-shadow: 0 0 3px #ccc;

margin: 13px;

position: relative;

}

.l_tree {

width: calc(100%);

padding-left: 15px;

}

.l_tree_branch {

width: 100%;

height: 100%;

display: block;

padding: 13px;

position: relative;

}

.l_tree_branch .l_tree_children_btn {

width: 12px;

height: 12px;

background-color: #515a68;

font-size: 8px;

text-align: center;

color: #bbbec1;

outline: none;

border: 0;

cursor: pointer;

border: 1px solid #bbbec1;

line-height: 11px;

margin-left: 5px;

}

ul.l_tree:before {

content: '';

border-left: 1px dashed #999999;

height: calc(100% - 24px);

position: absolute;

left: 10px;

top: 0px;

}

.l_tree,

.l_tree_branch {

position: relative;

}

.l_tree_branch::after {

content: '';

width: 18px;

height: 0;

border-bottom: 1px dashed #bbbec1;

position: absolute;

right: calc(100% - 10px);

top: 24px;

left: -5px;

}

.l_tree_container>.l_tree::before,

.l_tree_container>.l_tree>.l_tree_branch::after {

display: none;

}

.l_folder {

font-size:11px;

margin-left: 5px;

display: inline;

color: #bbbec1;

cursor: pointer;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值