在做网页的过程中,我们经常用到数据的查找,例如输入用户名,来找寻我们需要的信息,其实有两种方法,一种是将数据进行过滤和筛选,从度娘下面当的一个:
但是如果数据很多,后端不可能将数据全部发送给前端,那么有可能筛选就会出错,这时候我们拿到数据的属性,比如说按名字查找,拿到名字的字段,点击按钮,重新向后台发送请求,得到唯一的数据:
sub(){
console.log(this.checkform)
if(this.checkform.length != 0){
var search ="";
var flag = false;
var pcd="";
if(this.checkform.area == ""){
delete this.checkform.area;
}else {
var name= this.checkform.area;
pcd='{"name":"username","value":'+name+',"pattern":"=","OrAnd":"and"},';
flag = true;
delete this.checkform.area;
}
search += pcd;
this.$http({
method:"post",
url:"/api/member",
data:{
rows:this.pagesize,
page:this.page,
sort:"CreateTime",
order:"asc",
sys_search:'['+search+']'
}
}).then((res)=>{
this.data = res.data.rows;
this.total = res.data.total;
console.log(this.data);
})
}
},
因为请求是用node进行请求,具体就不多说啦,求大神多多指导。