Detailed usage of Vue more filter widget

Detailed usage of Vue more filter widget

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:
  • Vue.js implements table functions of multi-condition filtering, searching, sorting and paging
  • Vue classification filter method simple example
  • Vuejs uses filterBy and orderBy to implement search filtering and descending sorting of data
  • Use vue-router beforEach to implement the function of judging user login jump route filtering
  • Detailed explanation of multi-conditional filtering function based on Vue (similar to JD.com and Taobao functions)
  • VUE implements mobile list filtering function
  • The selector in ant-design-vue filters the input value
  • Vue input input box keyword filtering retrieval list data display
  • Vue implements multi-condition filtering of front-end lists
  • Vue filters data by input

<<:  CentOS 6 Compile and install ZLMediaKit analysis

>>:  Zabbix redis automatic port discovery script returns json format

Recommend

CentOS 6.5 installation mysql5.7 tutorial

1. New Features MySQL 5.7 is an exciting mileston...

MySQL 8.0.12 installation configuration method and password change

This article records the installation and configu...

Docker connects to the host Mysql operation

Today, the company project needs to configure doc...

Detailed explanation of MySQL phantom reads and how to eliminate them

Table of contents Transaction Isolation Level Wha...

Detailed steps for configuring virtual hosts in nginx

Virtual hosts use special software and hardware t...

How InnoDB implements serialization isolation level

Serialization implementation InnoDB implements se...

Nodejs implements intranet penetration service

Table of contents 1. Proxy in LAN 2. Intranet pen...

A possible bug when MySQL executes the sum function on the window function

When using MySql's window function to collect...

The difference between key and index in MySQL

Let's look at the code first: ALTER TABLE rep...

Detailed steps for adding hosts you need to monitor in zabbix

Add monitoring host Host 192.168.179.104 is added...

Implementing Priority Queue in JavaScript

Table of contents 1. Introduction to priority que...

How to implement Mysql scheduled tasks under Linux

Assumption: The stored procedure is executed ever...

Add a startup method to Linux (service/script)

Configuration file that needs to be loaded when t...

How to find identical files in Linux

As the computer is used, a lot of garbage will be...