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
Table of contents 1. Advantages of proxy vs. Obje...
Using the Vue language and element components, we...
Table of contents 1. Download 2. Install nginx an...
Due to the advantages of GTID, we need to change ...
Method 1: Use the SET PASSWORD command MySQL -u r...
Drag and drop is a common function in the front e...
1. Implementation principle of scrolling The scro...
1. Which three formats? They are: gif, jpg, and pn...
Table of contents Background 1. What is dns-prefe...
This article example shares the specific code of ...
MySQL escape Escape means the original semantics ...
As the most commonly used layout element, DIV play...
FastDFS & Nginx Integration: The tracker is c...
like LIKE requires the entire data to match, whil...
In the WeChat applet project, the development mod...