Coder Social home page Coder Social logo

vue-tree's Introduction

vue-tree

A simple tree component for vue.js

首先,感谢JiaxinCui,看了他的树形组件源码,按照他的代码和思路,模仿了一个 基于elementUI的横向树形组件用于公司的项目,附上他的项目代码MIT

####Demo图片: Image text

演示

A Demo

本地项目跑起来,输入网址http://localhost:8080/#/

# install
npm install
npm run dev

treeData示例

./tree.json

 其中,child即使是空数组,也要存在,并且,id不能重复,是数字

 treeData:[
        {
          "id": 1,
          "name": "优订购代发",
          "child": [
            {
              "id": 34,
              "name": "sea仓库商品管理",
              "child": []
            }
          ]
        }
 ]

使用示例

`App.vue`

  ```vue
  <template>
    <div id="app">
       <tree
            :treeData="treeData"
            v-model="ids"
            :withoutParents="withoutParents"
            :options="treeOptions"
          ></tree>
  </template>

  <script>
  import tree from '@/components/tree'

  export default {
    name: 'app',
    components: {  'tree':tree },
    data () {
      return {
         //包含父节点,必填项
         ids:[400],
          //不包含父节点,非必填项,当treeOptions对象中的withParents为false必须填,
          //而且初始数值跟ids一样
         withoutParents:[400],
          //treeOptions非必填项
         treeOptions:{
          //是否包含父节点,如果为false,则要添加withoutParents这个参数,如果为true则不需要添加
           withParents:false
         },
         数据结构在上面
         treeData:[]
      }
    }
  }
  </script>
  ```

设置选项

treeOptions设置说明

名称 类型 默认值 说明
withParents Boolean true 当为true时则不需要填写withoutParents参数,当为false时,withoutParents初始值要跟ids一样

-- 注意:本组件采用vue+elementUI,使用的是checkbox的样式

License

[MIT] ©

vue-tree's People

Contributors

summer-lin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.