1.2.8 • Published 7 years ago

vue2-lazy-tree v1.2.8

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

vue2-lazy-tree

first of all, i highly recommended to see the demo

and u will find out how to use this plugin

i must say, this doc is terrible, but the function is really good

features

  • node issue tip

  • normal tree

  • lazy loading

  • loading tip

  • dynamic add node

  • custom tree icon, use iconFont

  • custom icon style. color

  • ie9,10,11,spartan

notice:

del search function

because the chinese-to-pinyin package too large, and you can achieve u own search or filter function, so i del this useless func

loadingChild method

import { ZTree, ComboZTree, generateKey, getParentNode } from 'vue2-lazy-tree'

import ZTree from 'vue2-lazy-tree'

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification  publish to npm
npm run build

How to install the plugin

  npm install vue2-lazy-tree or cnpm install vue2-lazy-tree (国内)

How to use in u production

import { ZTree } from 'vue2-lazy-tree/dist/vue2-tree.min'
import 'vue2-lazy-tree/dist/vue2-tree.min.css'
Vue.use(ZTree)

Demo

npm install & npm run dev
    

属性

参数说明类型可选值默认值
options    配置项Object
treeData指定节点对象数组ArrayObject
     options: {
        labelKey: '',           { String } set the label field, default 'label'
        showCheckbox: true,  //是否支持多选,
        halfCheckedStatus: true,//控制父框是否需要半钩状态,
        
        lazy: true,     // 是否是异步加载数据
        load: this.loadingChild, // 异步加载数据方法
        
        iconClass: {                        // custom icon class, Default
            close: 'icon-youjiantou',
            open: 'icon-xiajiantou',
            add: 'icon-add'
        },
        iconStyle: {                        // custom icon style, sometimes u just need to set color
            color: '#108ee9'                // default #000
        },
        
        dynamicAdd: true,
        // function  handle display add button
        // return true or false, default true
        // [Function] param: { node } 
        dynamicAddFilter: (node) => {
            if (node.type === 1 || node.type === 2) {
                return true
            }
            return false
        },
        // function handle add node; the new node must have `dynamicAdd : true` property
        // the tree component rely on this show editor
        // param { node }
        // return Promise(parent.children) must bu children Array
        dynamicAddNode: [Function],
        // function handle save node; when successfull saved, the new node must del `dynamicAdd` property
        // the tree component rely on this save node
        // param { node, $event }
        // return Promise(node) must be node Object return from server
        dynamicSaveNode: [Function],
        // function handle leaf icon
        // param { node }
        // return { String } , iconfont class name, default ''
        leafIcon: [Function],
        
        // show issue tip
        warning: true,   
        // warning config   
        warningConfig: {
            title: (item) => 'lalal...',
            iconClass: (item) => 'icon-warning1',
            style: (item) => {
                return { color: 'red'}
            }
        }
     }
    
    /* 节点元素 */
    {
      id: 1,                    // 节点标志
      label: '一级节点',         // 节点名称
      open: true,               // 是否打开节点
      checked: false,           // 是否被选中
      parentId: null,           // 父级节点Id
      visible: true,            // 是否可见
      searched: false,          // 是否是搜索值,
      nodeSelectNotAll: false,  // 表示父框可以半钩状态
      leaf: true,               // 是否是叶子节点, 如果是叶子结点, lazy=true 时,显示 leafIcon, 此节点不再异步加载数据
      children: []              // 子节点,

    }

方法

方法名说明参数
getSelectedNodeIds若节点可被选择则返回目前被选中的节点Id所组成的数组被选中的节点Id所组成的数组
getSelectedNodes若节点可被选择则返回目前被选中的节点组成的数组被选中的节点所组成的数组

事件

事件名称    说明  回调参数    
node-click节点被点击时的回调共1个参数,节点组件本身。

iconfont

u can use build in iconfont class or u add it by u self iconFont

how to find the build in class:

// just go to the package folder, under node_modules/vue2-lazy-tree/
src/components/tree/assets/iconfont/demo_fontclass.html

package is copy from https://github.com/halower/vue2-tree

and when some new feature is test ok, i will pull a new request to halower

discuss

QQ group:255965810

contributor

Update History

  • add issue tip 16082017

  • fix getParentNode method 15082017

  • fix halfcheck bug del search func
    02082017

  • fix search bug, and require chinesetopinyin package 02082017

  • fix generateKey method bug 31072017

  • add label key property, set the label field 28072017

  • add node leaf 27072017

  • fix key bugs, add iconfont class 25072017

  • fix checkbox bugs, showCheckbox & halfCheckedStatus 25072017

  • Add how to use it in the production env 25072017

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.3

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago