RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
如何实现vue搜索和vue模糊搜索

小编给大家分享一下如何实现vue搜索和vue模糊搜索,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

成都创新互联是一家集网站建设,永善企业网站建设,永善品牌网站建设,网站定制,永善网站建设报价,网络营销,网络优化,永善网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

1、使用vue来实现一般搜索


   


   
      
         
         {{item1.name}}
      
    
submitQuery:function(){
  this.query = this.$refs.search.value.trim();
},
queryDate:function(list){
   if (this.query === '') {
     return list
   } 
   return list.filter((item)=>{
     if(item.name.indexOf(this.query) != -1){
      return item;
     }
   })
},

2、vue模糊搜索,原理都是一样的


   
     
   
   
      
   
   
      筛选
   
 
onSubmit() {
   this.query = this.$refs.search.value.trim();
   this.query1 = this.$refs.search2.value.trim();
},
queryDate:function(list){
   if (this.query === '' && this.query1 === '') {
     return list
   } 
   else if (this.query !== '' && this.query1 === '') {
     return list.filter(item => {
       if (item.name.indexOf(this.query) !== -1) {
         return item
        }
     })
    } 
    else if (this.query === '' && this.query1 !== '') {
     return list.filter(item => {
        if (item.mobile.indexOf(this.query1) !== -1) {
          return item
         }
      })
    } 
    else if (this.query !== '' && this.query1 !== '') {
      return list.filter(item => {
        if (item.name.indexOf(this.query) !== -1 && item.mobile.indexOf(this.query1) !== -1) {
          return item
        }
      })
    }
},

以上是“如何实现vue搜索和vue模糊搜索”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


当前题目:如何实现vue搜索和vue模糊搜索
文章分享:http://sczitong.cn/article/pdehoc.html