uniAPP下的搜索栏模糊查询

首先添加导航栏代码

<uni-search-bar @input="inoutWatcher" @confirm="doSearch" placeholder="请输入想要查询的"></uni-search-bar>

@input为搜索事件会根据你输入的直接进行显示

@confirm也为搜索事件按下Enter建显示

placeholder 为标题

接下来

事件监听

图片分别为两个监听事件 

doSearch(e){
				//console.log(e.value);
				uni.request({
				    url: 'http://localhost:8070/user/list_by_phone/'+e.value,//仅为示例,并非真实接口地址。
				    success: (res) => {	 
				       //  console.log(res.data);
						 this.userList = res.data.data;
						 this.pageTotle = res.data.rows;
				    }
				});
			},
			//监听用户输入字符的变化
			inoutWatcher(e){
				uni.request({
				    url: 'http://localhost:8070/user/list_by_phone/'+e,//仅为示例,并非真实接口地址。
				    success: (res) => {	 
				       //  console.log(res.data);
						 this.userList = res.data.data;
						 this.pageTotle = res.data.rows;
				    }
				});
			}

 可以看出doSearch(e){}  inoutWatcher(e){}  分别为我们自己设置的变量不过尽量 见名知意

e 为参数变量 接受输出的东西

运行就可以得到我们需要的东西非常简单

数据库的模糊查询

代码讲解

<select id="selectByPhone" parameterType="String" resultMap="BaseResultMap">
    select * from auth_user where phone like '%' #{phone} '%'
  </select>

 这段代码

重点like

like是需要和%搭配使用的

在where条件之后与其他确定的条件不同

记住使用顺序就可以达到目的

结束 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值