0.1.1 • Published 4 years ago

fun-tree v0.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

fun-tree

A folder tree project by vue

Document English / 中文

DEMO Live Demo

NPM

npm install --save fun-tree

Import

./main.js

import FunTree from 'fun-tree/dist/fun-tree.js'
import 'fun-tree/dist/fun-tree.css' // Optional

Vue.use(FunTree)

>ES6

```js
import FunTree from 'fun-tree/dist/fun-tree.js'
import 'fun-tree/dist/fun-tree.css' // Optional

components: {
  FunTree: FunTree,
},

If you want to customer css, you can not import fun-tree.css

Usage

Add a component inside your template
HTML

<FunTree :trees="yourTreeData"
         @clickEvent="myEvent()">
</FunTree>

Javascript

export default {
  name: "App",
    data() {
      return {
        trees: [
          { text: "Level1", selected: true },
          {
            text: "Level2",
            opened: true,
            children: [
              { text: "Level2-1", disabled: true },
              { text: "Level2-2", icon: "node-icon-music", selected: true },
              { text: "Level2-3", icon: "node-icon-word" },
            ],
          },
          {
            text: "Level3",
            opened: false,
            children: [
              { text: "Level3-1" },
              { text: "Level3-2", icon: "node-icon-excel" },
              { text: "Level3-3", icon: "node-icon-ppt", selected: true },
            ],
          },
        ],
      };
    },
    methods: {
      myEvent(node, actions, values) {
        console.log(node); // current node vue component
        console.log(actions); // do actions with current node
        console.log(values); // current node values  
      },
    }
}

Options

NameTypeDefaultRequiredDescription
treesArray yestrees data
clickEventFunctionundefinednotree's node click event
checkboxShowBooleantruenoset it show checkbox
checkboxActionBooleantruenoset it checkbox action

Event

@clickEvent(node, actions, values)

node : current node vue component
actions : do actions with current node
values : current node values

Methods in actions

MethodParamsDescription
addChild(object) nodeDataadd child with this node
removeChildrenremove this node's children
removeNoderemove this node
checkedset this node's selected true or false
openset this node's opened = true
closeset this node's opened = false

Node data

NameTypeDefaultRequiredDescription
textStringNew Nodeyesset node show text
iconStringnoicon class name
openedBooleanfalsenoset node opened
selectedBooleanfalsenoset node selected
disabledBooleanfalsenoset node disabled
childrenArrayfalsenoset node children

Default icon class

ImageClass Name
node-icon-closed
node-icon-open
node-icon-disabled
node-icon-not
node-icon-danger
node-icon-image
node-icon-music
node-icon-word
node-icon-excel
node-icon-ppt

Customer CSS Class

Class NameDescription
tree-nodeNode
tree-contentNode content (checkbox, icon, text).
tree-content:hoverNode content hover
tree-button-unfoldNode unfold button.
tree-button-foldNode fold button.
tree-button-noneNode button none.
tree-checkboxNode checkbox default.
tree-checkbox:hoverNode checkbox hover.
tree-checkbox-checkedNode checkbox checked.
tree-wordNode word.

License

This is open-sourced software licensed under the MIT license.

0.1.0

4 years ago

0.1.1

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago