安装
npm install --save @riophae/vue-treeselect
使用
在组件中加入
<treeselect
v-model="value"
placeholder="请选择"
:options="data"
/>
script
export default {
components: { Treeselect },
data() {
return {
value: null,
data: [ {
id: '1',
label: '一级',
children: [ {
id: '2',
label: '二级',
}, {
id: '3',
label: '二级-1',
} ],
}, {
id: '4',
label: '一级-1',
}, {
id: '5',
label: '一级-2',
} ]
}
}
}