当前位置:网站首页>树形下拉选择框el-select结合el-tree效果demo(整理)
树形下拉选择框el-select结合el-tree效果demo(整理)
2022-06-29 06:38:00 【我是开心呀】
效果图:
<template>
<div class="box">
<el-select size="small" placeholder="请选择" clearable v-model="selectLabel" @clear="selectClear">
<el-option class="option-style" :label="selectLabel" :value="selectValue">
<el-input class="search" size="small" placeholder="输入关键字进行过滤" v-model="keywork" @click.stop.native>
</el-input>
<el-tree ref="tree" :data="treeDate" :props="treeProps" :show-checkbox="showCheckbox"
:filter-node-method="filterNode" @node-click="nodeClick" @check-change="checkChange">
<div slot-scope="{node, data}">
<i class="el-icon-warning-outline"></i>
<span :class="[{'tree-click': treeClick==data.value}]">{
{
data.label}}</span>
</div>
</el-tree>
</el-option>
</el-select>
</div>
</template>
<script>
export default {
name: "test",
components: {
},
data() {
return {
treeClick: null, //点击样式
keywork: null, //搜索关键字
selectLabel: null, //下拉框显示名称
selectValue: null, //下拉框显示ID
treeDate: [{
label: "主-测试0",
value: 0,
children: [{
label: "子-测试0",
value: 6
}]
},
{
label: "主-测试1",
value: 1,
children: [{
label: "子-测试1",
value: 7
}]
},
{
label: "主-测试2",
value: 2,
children: [{
label: "子-测试2",
value: 8
}]
},
{
label: "主-测试3",
value: 3,
children: [{
label: "子-测试3",
value: 9
}]
},
{
label: "主-测试4",
value: 4,
children: [{
label: "子-测试4",
value: 10
}]
},
{
label: "主-测试5",
value: 5,
children: [{
label: "子-测试6",
value: 11
},
{
label: "子-测试7",
value: 12
}
]
}
],
treeProps: {
children: "children",
label: "label"
}
}
},
props: {
// treeDate: {
//树状数据
// type: Array,
// default: ()=>{
}
// },
// treeProps: {
//树状规则
// type: Object,
// default: ()=>{
}
// },
showCheckbox: {
//是否可选择
type: Boolean,
default: true
}
},
methods: {
selectClear() {
this.treeClick = null;
this.selectLabel = null;
this.selectValue = null;
},
filterNode(value, data) {
if (!value) {
return true;
}
return data.label.indexOf(value) !== -1;
},
nodeClick(obj, node) {
this.treeClick = obj.value;
this.selectLabel = obj.label;
this.selectValue = obj.value;
console.log(obj, node);
},
checkChange(obj, node) {
console.log(obj, node);
},
},
watch: {
keywork(val) {
this.$refs.tree.filter(val);
}
},
computed: {
},
created() {
},
mounted() {
},
beforeDestroy() {
}
}
</script>
<style scoped>
.box {
width: 100%;
height: 100%;
margin: 1rem;
}
.search {
width: calc(100% - 8px - 0.5rem);
margin: 0 0.5rem;
}
.option-style {
padding: 0;
width: 100%;
height: 100%;
background-color: #FFFFFF;
}
.tree-click {
color: #4D74D6;
font-weight: 600;
}
/deep/ .el-tree-node__content {
padding: 0.25rem;
}
/deep/ .el-icon-caret-right {
font-size: 0;
}
</style>
边栏推荐
- 转:侯宏:企业数字化转型的关键不是技术,而是战略
- 数据库-同义词
- Li Kou daily question - day 30 -1281 Difference of sum of bit product of integer
- [translation] [Chapter 2 ②] mindshare PCI Express technology 3.0
- The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
- Save token get token refresh token send header header
- Multithreading tool class completabilefuture
- package.json的所有配置项及其用法,你都熟悉么
- 消息队列之通过幂等设计和原子锁避免重复退款
- Qt 自定义位操作类
猜你喜欢

NoSQL数据库介绍

Crawler data analysis (introduction 2-re analysis)

The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail

Creating a new generation of production and service tools with robot education

IDEA 集成 码云

Single application and microservice application

关于DDNS

json tobean

Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function

jetson tx2
随机推荐
关于端口转发程序的一点思考
QT foreach keyword
Json tobean
Better than postman! Apipost knows more about Chinese programmers! How delicious!
作为一名合格的网工,你必须掌握的 DHCP Snooping 知识!
QT qlineedit details
json tobean
Database - Synonyms
Single application and microservice application
Creating a new generation of production and service tools with robot education
Testing grpc service with grpcui
Flutter is configured with a domestic image and connected to the real machine
Open source 23 things shardingsphere and database mesh have to say
UVM authentication platform
Ribbon service invocation and load balancing
[translation] [Chapter 2 ③] mindshare PCI Express technology 3.0
idea控台中文乱码问题【亲测有效】
Instanceklass "suggestions collection" of hotspot class model
List集合实现分页
QT qframe details