项目作者: arixse

项目描述 :
A Vue.2x component of ztree
高级语言: HTML
项目地址: git://github.com/arixse/vue-ztree.git
创建时间: 2018-07-26T16:15:18Z
项目社区:https://github.com/arixse/vue-ztree

开源协议:

下载


vue-ztree

A Vue.2x component of ztree 👍

How to install ztree-for-vue?

First,you should install jquery and ztree package,you can install them with anyway,such as script,es6,amd or commonjs,the ztree-for-vue only need a global veriable $ and $.fn.ztree.You should also need to load the css files for ztree.

  1. npm install ztree-for-vue --save-dev
  2. #or yarn add ztree-for-vue -D

How to use it?

  1. <template>
  2. <div id="app">
  3. <vue-ztree :treeNodes="treeNodes" @onClick="handleTreeClick" :check="check" @onCheck="handleCheck"></vue-ztree>
  4. </div>
  5. </template>
  1. import VueZtree from "ztree-for-vue";
  2. const nodes= [
  3. {
  4. name: '父节点1',
  5. id:0,
  6. children: [
  7. {name: '子节点1',id:1},
  8. {
  9. name: '子节点2',
  10. id:2,
  11. children:[
  12. {name:'子节点3',id:3}
  13. ]
  14. }
  15. ]
  16. }
  17. ];
  18. export default {
  19. name: "app",
  20. data() {
  21. return {
  22. treeNodes: nodes,
  23. check:{
  24. enable:true
  25. }
  26. };
  27. },
  28. components: {
  29. VueZtree
  30. },
  31. methods:{
  32. handleTreeClick(event,treeId,treeNode) {
  33. console.log(event,treeId,treeNode)
  34. },
  35. handleCheck(event,treeId,treeNode) {
  36. console.log(event,treeId,treeNode);
  37. }
  38. }
  39. };

Props

  • treeName (string)
    the global attribute name
  • treeNodes (required, object)
    the zTreee Nodes data
  • async (object)
    to load zTree Nodes as async(the zTree async setting)
  • check (object)
    the zTree check setting(the zTree check setting)
  • data (object)
    the zTree data setting
  • edit (object)
    the zTree eidt setting
  • view (object)
    the zTree view setting
    Please go http://www.treejs.cn/v3/api.php to get more infomations

    Event

    ztree-for-vue provide some events looks like the ztree callback,
    we can only listen the events that we need ,the events that we not need will not be emited.
    1. const callbacks = [
    2. 'beforeAsync',
    3. 'beforeCheck',
    4. 'beforeClick',
    5. 'beforeCollapse',
    6. 'beforeDblClick',
    7. 'beforeDrag',
    8. 'beforeDragOpen',
    9. 'beforeDrop',
    10. 'beforeEditName',
    11. 'beforeExpand',
    12. 'beforeMouseDown',
    13. 'beforeMouseUp',
    14. 'beforeRemove',
    15. 'beforeRename',
    16. 'beforeRightClick',
    17. 'onAsyncError',
    18. 'onAsyncSuccess',
    19. 'onCheck',
    20. 'onClick',
    21. 'onCollapse',
    22. 'onDblClick',
    23. 'onDrag',
    24. 'onDragMove',
    25. 'onDrop',
    26. 'onExpand',
    27. 'onMouseDown',
    28. 'onMouseUp',
    29. 'onNodeCreated',
    30. 'onRemove',
    31. 'onRename',
    32. 'onRightClick'
    33. ]

    LICENSE

    MIT