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

Proxy realizes the principle of two-way binding of Vue3 data

Table of contents 1. Advantages of proxy vs. Obje...

Vue uses monaco to achieve code highlighting

Using the Vue language and element components, we...

Analyze the method of prometheus+grafana monitoring nginx

Table of contents 1. Download 2. Install nginx an...

Detailed tutorial on setting password for MySQL free installation version

Method 1: Use the SET PASSWORD command MySQL -u r...

Native js drag and drop function to create a slider example code

Drag and drop is a common function in the front e...

Vue uses better-scroll to achieve horizontal scrolling method example

1. Implementation principle of scrolling The scro...

What are the image file formats and how to choose

1. Which three formats? They are: gif, jpg, and pn...

Vue+js click arrow to switch pictures

This article example shares the specific code of ...

Detailed explanation of the usage of the ESCAPE keyword in MySQL

MySQL escape Escape means the original semantics ...

FastDFS and Nginx integration to achieve code analysis

FastDFS & Nginx Integration: The tracker is c...

Commonplace talk about the usage of MYSQL pattern matching REGEXP and like

like LIKE requires the entire data to match, whil...

WeChat applet canvas implements signature function

In the WeChat applet project, the development mod...