1.2.3 • Published 6 years ago

vue-trees v1.2.3

Weekly downloads
17
License
ISC
Repository
-
Last release
6 years ago

vue-trees

a tree UI base on vue 2.X

install

npm install vue-trees  --save
or
cnpm i vue-trees  -S

Quick start

import Vue from 'vue'
import vueTrees from 'vue-trees'

Vue.use(vueTrees)

API DOC (中文文档)

data Property

The data property does not support properties inherited from the prototype chain (if you can use to consider whether the under-complex, it is recommended to check the code)

ParamDescriptionTypesEditableDefault value
title    Node nameString-
expandedWhether the node is expandedBooleanYfalse
checkedNode check box is selectedBooleanYfalse

tree Property

ParamDescriptionTypesEditableDefault value
type    Tree styleStringYdefault
canCheck    Node can chooseBooleanYfalse
draggableWhether the node can dragBooleanYfalse
dragAndExpandedWhether to expand after draggingBooleanYtrue
controlAdd or delete treesBooleanYfalse
isSolidWhether it is solidBooleanYfalse
banCheckProhibition of choiceBooleanYfalse
bgColorBackground color (default type is useless)StringY#fff
fontColorFont color (default type is useless)StringY#000

node event

ParamDescriptionTypesEditableArguments
beforeAddNodeIncrease the node before the trigger event (return 'no' means no new)FunctionY1:Parent node
afterAddNodeIncrease the node after the trigger eventFunctionY1:Add node,2:Parent node
beforeDelNode    Delete the node before the trigger event (return 'no' means do not delete)FunctionY1:Current node
afterAddNodeEvent triggered after node deletionFunctionY1:Current node
beforeDragNode    Drag the node before the trigger event (return 'no' means do not delete)FunctionY1:Drag node,2:Target node
afterDragNodeDrag the node after the trigger eventFunctionY1:Drag node, 2:Target node

Demo

<template>
  <div class="hello">
    <vue-trees :data="data1" :type="'fold'" :canCheck="canCheck"  :control="control" :bgColor="bgColor" :fontColor="fontColor"></vue-trees>
    <vue-trees :data="data"  :canCheck="canCheck"  :control="control" :afterAddNode="add" :beforeAddNode="beforeAddNode" ></vue-trees>
    <span class="change" @click="mod()">修改</span>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      data: [{"title": "第一个", 
        "expanded": true,  
        "children": [{
          "title": "1-1",
          "expanded": true,
          "children": [{
            "title": "1-1-1",
             "children": [{
               "title": "1-1-1-1"
             }]
          }, {
            "title": "1-1-2"
          }, {
            "title": "1-1-3"
          }]
        }]
      },
      {
        "title": "第二个" 
      }],
      data1: [{"title": "第一个", 
        "expanded": true,  
        "children": [{
          "title": "1-1",
          "expanded": true,
          "children": [{
            "title": "1-1-1",
             "children": [{
               "title": "1-1-1-1"
             }]
          }, {
            "title": "1-1-2"
          }, {
            "title": "1-1-3"
          }]
        }]
      },
      {
        "title": "第二个" 
      }],
      canCheck: true,
      control: false,
      bgColor: '#339999',
      fontColor: 'white'
    }
  },
  mounted () {
    
  },
  methods: {
    mod () {
      console.log(this.data)
      this.control = !this.control
    },
    add: function() {
      console.log('Now is add')
    },
    beforeAddNode (node) {
      console.log(node)
      return 'no'
    }
  }
}
</script>

<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
.hello {
  padding: 20px;
}
.change {
  background: #336699;
  padding: 5px 20px;
  color: white;
  border-radius: 5px
}
</style>

Example of effect

If you can not see my picture please go my github

If you find any problems during use please feel free to Issues

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.2

6 years ago

1.0.3

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago