This article example shares the implementation method of the Vue More Filter Item widget for your reference. The specific content is as follows Effect: It is a simple little effect. When there are many filtering conditions, only a few items will be displayed by default, so it will not feel redundant. If necessary, you can click to expand and filter more conditions. It can also automatically determine the size of the interface and decide whether more filtering items are needed. "Query and reset" are directly built into the component, which facilitates the implementation of component styles and can also be used for slots. Normal large screen Smaller resolution You can see that there are more filtering buttons, you can click the drop-down Slots Code: <template> <div :class="['colla-wrap']" ref="filter"> <div class="colla-box" ref="filterCont" :style="maxWidth ? 'max-width:' + maxWidth: ''"> <slot></slot> </div> <div class="ctrl"> <div class="deal-b" > <el-button size="mini" type="primary" icon="el-icon-search" @click="clickSearch">Search</el-button> <el-button size="mini" plain icon="el-icon-refresh-left" @click="clickReset">Reset</el-button> <slot name="moreBtns"></slot> <div class="deal-b" @click="showCollapse" v-if="autoExpend.more"> <i class="el-icon-arrow-down turnDown" v-if="!autoExpend.collapseVisible"></i> <i class="el-icon-arrow-up turnUp" v-if="autoExpend.collapseVisible"></i> <div v-if="!autoExpend.collapseVisible" class="more-words">More filter items</div> <div v-if="autoExpend.collapseVisible" class="more-words">Collapse filter</div> </div> </div> </div> </div> </template> <script> export default={ data(){ return { collapseData:{ collapseVisible:false }, //Automatically fold to display more filter items autoExpend:{ more:false, collapseVisible:false, hasTop:false, hasFilter:false }, } }, props:['maxWidth'], mounted(){ this.watchScrollHeight() window.addEventListener("resize", () => { this.watchScrollHeight() }); }, methods:{ clickSearch(){ this.$emit('clickSearch') }, clickReset(){ this.$emit('clickReset') }, showCollapse(){ this.methods('showCollapse') }, showCollapse(){ this.autoExpend.collapseVisible = !this.autoExpend.collapseVisible this.$refs.filterCont.style.height = this.autoExpend.collapseVisible?'auto':'50px' } //Try to monitor this heightwatchScrollHeight(){ let filter = this.$refs.filter; if(filter){ this.$nextTick(() => { this.autoExpend.more = $(filter).find(".colla-box")[0].scrollHeight > 50; }) } //Judge whether there is an element node below to determine whether this slot is displayed //Judge the normal search box position slot if (this.$refs.filterCont&&this.$refs.filterCont.childNodes.length) { this.autoExpend.hasFilter = true } } } } </script> <style scoped lang="scss"> .colla-wrap{ width: 100%; .colla-box{ max-width: calc(100% - 400px); float: left; box-sizing: border-box; overflow: hidden; height: 50px; >div,button{ float: left; margin-right: 20px; margin-bottom: 20px; } } .ctrl{ display: flex; align-items:flex-start; justify-content: flex-start; color: #409EFF; button{ margin-right: 20px; } .deal-b{ display: flex; align-items:flex-start; flex-wrap: nowrap; .deal-b{ margin-right: 0; margin-bottom: 0; margin-top: 5px; display: flex; align-items: center; cursor: pointer; color: #409EFF; .more-words{ min-width: 75px; } i{ color: #409EFF; margin-right: 5px; } } } } } </style> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: CentOS 6 Compile and install ZLMediaKit analysis
>>: Zabbix redis automatic port discovery script returns json format
1. New Features MySQL 5.7 is an exciting mileston...
This article records the installation and configu...
Today, the company project needs to configure doc...
Table of contents Transaction Isolation Level Wha...
Virtual hosts use special software and hardware t...
Serialization implementation InnoDB implements se...
Table of contents 1. Proxy in LAN 2. Intranet pen...
When using MySql's window function to collect...
Let's look at the code first: ALTER TABLE rep...
Add monitoring host Host 192.168.179.104 is added...
Table of contents 1. Introduction to priority que...
Assumption: The stored procedure is executed ever...
Configuration file that needs to be loaded when t...
As the computer is used, a lot of garbage will be...
Table of contents 1. The writing order of a compl...