1.0.1 • Published 5 years ago

vue-x-tree v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

vue-x-tree

Install

npm i vue-x-tree --save

Tree props

属性说明类型默认值
tree生成tree的数据Array[]
keys节点字段名Object{titleKey: 'title', childrenKey: 'children', valueKey: 'value'}
value选中的项目的集合可以使用v-model绑定Array[]
link选择时是否联动Booleantrue
render自定义的渲染内容FunctionNull

keys

属性说明默认值
titleKey标题title
childrenKey子节点children
valueKeycheckbox value值value

children props

属性说明类型默认值
showDown子节点展开状态Booleanture
render自定义的子节点渲染内容FunctionNull

demo

<XTree :data="data" v-model="model" :keys="keys" :link="true"></XTree>
data() {
    return {
        model: [1, 2],
        keys: {
            titleKey: 'title',
            childrenKey: 'children',
            valueKey: 'id'
        },
        data: [{
            title: 'A-1',
            id: 1,
            render: (h, { root, node, data }) => {
                return h('span', 'THIS IS RENDER')
            },
            children: [{
                title: 'B-1-1',
                id: 2,
            }, {
                title: 'B-1-2',
                id: 3,
            }]
        }, {
            title: 'A-2',
            id: 4,
            children: [{
                title: 'B-2-1',
                id: 5,
            }, {
                title: 'B-2-2',
                id: 6,
                showDown: false,
                children: [{
                    title: 'C-2-1',
                    id: 10,
                }, {
                    title: 'C-2-2',
                    id: 11,
                }]
            }]
        }]
    }
}

demo.gif