代码拉取完成,页面将自动刷新
基于vue 3的树形组件。
A highly customizable tree component for vue 3.
npm
npm install @tinywisp/vue-tree --save
引入
import VueTree from '@tinywisp/vue-tree'
示例
<template>
<div id="app">
<vue-tree :tree="tree" ref="tree" class="tree" />
</div>
</template>
<script>
import VueTree from '@tinywisp/vue-tree'
export default {
name: 'App',
components: {
VueTree
},
data() {
return {
tree: [
{
id: 1,
title: 'ROOT',
hasChild: true,
children: [
{
id: 2,
title: 'child 1',
},
{
id: 3,
title: 'child 2',
hasChild: true,
children: [
{
id: 4,
title: 'child 2-1'
},
{
id: 5,
title: 'child 2-2'
},
{
id: 6,
title: 'child 2-3'
}
],
},
{
id: 7,
title: 'child 3'
},
{
id: 8,
title: 'child 4'
}
]
}
]
}
}
}
</script>
<style scoped>
.tree {
width: 200px;
height: 300px;
}
</style>
npm
npm install @tinywisp/vue-tree --save
import the library
import VueTree from '@tinywisp/vue-tree'
usage
<template>
<div id="app">
<vue-tree :tree="tree" ref="tree" class="tree" />
</div>
</template>
<script>
import VueTree from '@tinywisp/vue-tree'
export default {
name: 'App',
components: {
VueTree
},
data() {
return {
tree: [
{
id: 1,
title: 'ROOT',
hasChild: true,
children: [
{
id: 2,
title: 'child 1',
},
{
id: 3,
title: 'child 2',
hasChild: true,
children: [
{
id: 4,
title: 'child 2-1'
},
{
id: 5,
title: 'child 2-2'
},
{
id: 6,
title: 'child 2-3'
}
],
},
{
id: 7,
title: 'child 3'
},
{
id: 8,
title: 'child 4'
}
]
}
]
}
}
}
</script>
<style scoped>
.tree {
width: 200px;
height: 300px;
}
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。