ElementUI's el-select combined with el-tree.
- Online examples https://yujinpan.github.io/el-select-tree/
npm install --save el-select-tree
If your project does not use element-ui, you need to introduce a separate element-ui package, like this:
import 'el-select-tree/lib/element-ui';
import Vue from 'vue';
import ElSelectTree from 'el-select-tree';
Vue.use(ElSelectTree);
import ElSelectTree from 'el-select-tree';
export default {
components: {
ElSelectTree
}
};
<template>
<el-select-tree
width="120px"
placeholder="请选择内容"
:data="treeData"
:disabled-values="disabledValues"
v-model="value"
></el-select-tree>
</template>
<script>
import ElSelectTree from 'el-select-tree';
export default {
components: {
ElSelectTree
},
data() {
return {
value: 2,
treeData: [
{
value: 1,
label: 'text1',
children: [{ value: 5, label: 'text5' }, { value: 6, label: 'text6' }]
},
{ value: 2, label: 'text2' },
{ value: 3, label: 'text3' },
{ value: 4, label: 'text5' }
],
disabledValues: [3]
};
}
};
</script>
name | type | description |
---|---|---|
value/v-model |
*/*[] |
bound value, the type must be array if attribute's multiple is true |
data |
object[] |
select options, is a tree data |
props |
object |
tree data props, default: { value: 'value', label: 'label', children: 'children' } |
multiple |
boolean |
multiple selection, default: false |
placement |
string |
extends ElementUI placement, default: botttom-start |
size |
string |
extends ElementUI size, default: samll |
disabled |
boolean |
selection disabled, default: false |
disabledValues |
*[] |
options disabled |
placeholder |
string |
placeholder text, default: '请选择' |
checkStrictly |
boolean |
select any level, default: false |
defaultExpandAll |
boolean |
expand all tree node, default: false |
clearable |
boolean |
cleanup options, default: false |
change(value)
options change, return changed value