当前位置:网站首页>Tree drop-down selection box El select combined with El tree effect demo (sorting)
Tree drop-down selection box El select combined with El tree effect demo (sorting)
2022-06-29 07:09:00 【I am happy】
design sketch :
<template>
<div class="box">
<el-select size="small" placeholder=" Please select " clearable v-model="selectLabel" @clear="selectClear">
<el-option class="option-style" :label="selectLabel" :value="selectValue">
<el-input class="search" size="small" placeholder=" Enter keywords to filter " 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, // Click on the style
keywork: null, // Search for keywords
selectLabel: null, // The drop-down box displays the name
selectValue: null, // The drop-down box displays ID
treeDate: [{
label: " Lord - test 0",
value: 0,
children: [{
label: " Son - test 0",
value: 6
}]
},
{
label: " Lord - test 1",
value: 1,
children: [{
label: " Son - test 1",
value: 7
}]
},
{
label: " Lord - test 2",
value: 2,
children: [{
label: " Son - test 2",
value: 8
}]
},
{
label: " Lord - test 3",
value: 3,
children: [{
label: " Son - test 3",
value: 9
}]
},
{
label: " Lord - test 4",
value: 4,
children: [{
label: " Son - test 4",
value: 10
}]
},
{
label: " Lord - test 5",
value: 5,
children: [{
label: " Son - test 6",
value: 11
},
{
label: " Son - test 7",
value: 12
}
]
}
],
treeProps: {
children: "children",
label: "label"
}
}
},
props: {
// treeDate: {
// Tree data
// type: Array,
// default: ()=>{
}
// },
// treeProps: {
// Tree rule
// type: Object,
// default: ()=>{
}
// },
showCheckbox: {
// Whether you can choose
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>
边栏推荐
- [C language] flexible array
- JVM系列之对象深度探秘
- Idea common plug-ins
- Object detection - VIDEO reasoning using yolov6
- Why should enterprises do more application activities?
- JDBC连接数据库,socket发送客户端。
- Qt 程序打包发布-windeployqt工具
- [translation] [Chapter 2 ②] mindshare PCI Express technology 3.0
- Analytic hierarchy process
- VerilogA - dynamic comparator
猜你喜欢

NoSQL数据库介绍

Exclusive download. Alibaba cloud native brings 10+ technical experts to bring new possibilities of cloud native and cloud future

Open source 23 things shardingsphere and database mesh have to say

CI工具Jenkins安装配置教程

Configuring the flutter development environment

Suggestions on digital transformation of large chemical enterprises

Chapter V online logic analyzer signaltap

Multimodal learning pooling with context gating for video classification

用机器人教育创造新一代生产和服务工具

Idea integrated code cloud
随机推荐
QT container class
解析学习幼儿机器人教育的浪潮
Differences between JSON objects and JSON strings
分享 10 个 JS Promise 相关的面试题
flutter配置国内镜像,连接真机
国内代码托管中心- 码云
Flutter is configured with a domestic image and connected to the real machine
RedisTemplate处理hash整数类型的问题解析
. NETCORE uses redis to limit the number of interface accesses
大型化工企业数字化转型建议
Li Kou daily question - day 30 -1523 Number of bit 1
NoSQL数据库之Redis(四):Redis的发布和订阅
Move disassembly of exclusive delivery of script (the first time)
QT program packaging and publishing windeployqt tool
Crawler data analysis (introduction 2-re analysis)
【OSPF引入直连路由时巧借静态黑洞路由做汇总】
消息队列之通过幂等设计和原子锁避免重复退款
NoSQL数据库介绍
Redistemplate handles hash integer type problem resolution
RPC and RMI