前端模糊查询

一般情况下,模糊查询是通过调用后台接口实现的,今天我在项目中,尝试了一下简单的前端模糊查询。

<el-input v-model="filterData" style="width: 80%;"></el-input>
        
    <span slot="footer" class="dialog-footer">
         <el-button @click="dialogTableVisible = false">取消</el-button>
         <el-button type="primary"  @click="filterHandler">确定</el-button>
    </span>

//筛选
filterShow(){
this.filterData = ''
this.dialogTableVisible = true
},
//筛选确定
filterHandler(){
this.dialogTableVisible = false
var len = this.passTable.length;
var reg = new RegExp(this.filterData);
this.passTable.map(item=>{
//如果字符串中不包含目标字符会返回-1
if(item.checkMessage.match(reg)){
this.passTable2.push(item);
}
})
this.passTable = this.passTable2
},

猜你喜欢

转载自www.cnblogs.com/yinxingen/p/9049512.html