vue vue搜索 vue模糊搜索

来源:互联网 发布:数据库黑匣子 编辑:程序博客网 时间:2024/06/16 10:35

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

<form action="" @submit="submitQuery" class="all_two">     <el-input v-model="input" placeholder="请输入内容" ref="search" style="width:300px;"></el-input></form><div class="all_three">      <div v-for="item in this.$store.state.chufang.alldata">            <div v-for="item1 in queryDate(item.cabinet)" >                 <input type="checkbox" name="checkbox"  value="checkbox" style="zoom:200%;" :checked="item1.checks==0? true:false">                 <span>{{item1.name}}</span>            </div>       </div></div>
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模糊搜索,原理都是一样的

 <el-form :inline="true" :model="formInline" class="demo-form-inline mt15">      <el-form-item>          <el-input v-model="formInline.name" ref="search"   placeholder="姓名"></el-input>      </el-form-item>      <el-form-item>           <el-input v-model="formInline.phone" ref="search1"  placeholder="手机号"></el-input>      </el-form-item>      <el-form-item>            <el-button type="primary" @click="onSubmit">筛选</el-button>      </el-form-item> </el-form>
onSubmit() {      this.query = this.$refs.search.value.trim();      this.query1 = this.$refs.search1.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                }           })        }},  







阅读全文
'); })();
1 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 小学软笔书法教程 书法笔法 小学生硬笔楷书字帖 毛笔字帖行书入门 毛笔行书讲座 毛笔字帖行书 毛笔字行书教程 书法作品图片小学生 书法纸 书法纸模板 书法纸图片 书法纸写古诗格式图片 书法作品纸 硬笔书法米字格空白字帖用纸 硬笔书法 纸 毛笔书法纸 硬笔书法比赛用纸 硬笔书法作品欣赏a4纸 硬笔书法作品纸格式 硬笔书法字帖纸 a4硬笔书法纸 硬笔书法纸米字格 小学生硬笔书法纸 硬笔书法作品格式纸 硬笔书法田字格纸 硬笔书法练习纸 米字格硬笔书法纸 书法纸格式 王乃勇书法 怎样学书法 书法讲堂 彭洪顺书法 如何学好书法 学书法的好处 书法交易网 中国书法网书法欣赏 中国书法教育网 当代书法网 书法拍卖网 中国书法名家网 中国硬笔书法网