最近在使用vue写webapp在,一些感觉比较有意思的分享一下。

1:input输入框:

<input class="s-search-text" placeholder="猜你喜欢我们" id="s-search-text" ref="searchval" v-model="message" @keyup="search">

2:对input输入框的keyup事件进行处理,通过每输入一个字符触发一次keyup事件,来对接口进行数据请求。

search () {
let searchText = this.$refs.searchval.value
if (searchText =='') {
return
} else {
this.closeState = true
this.searchState.showsug = true
this.searchState.searchtext = this.$refs.searchval.value
this.$emit('searchstate', this.searchState)
}
axios.get('http://localhost:3000/search/suggest?keywords=' + searchText, {}, {headers:{'Content-Type':'application/x-www-form-urlencoded'}})
.then((res) => {
if (res.data.code == 200) {
this.$emit('search', res.data.result.allMatch)
}
})
.catch((err) => {
console.log(err)
})
},

  github地址:https://github.com/xu-jinkai/vue-music

  

vue中input输入框的模糊查询实现的更多相关文章

  1. vue实现input输入框的模糊查询

     最近在用uni-app做一个项目,使用的框架还是vue,想了好久才做出来 . HTML代码部分 <input type="text" focus class="s ...

  2. vue实现输入框的模糊查询(节流函数的应用场景)

    上一篇讲到了javascript的节流函数和防抖函数,那么我们在实际场合中该如何运用呢? 首先,我们来理解一下:节流函数首先是节流,就是节约流量.内存的损耗,旨在提升性能,在高频率频发的事件中才会用到 ...

  3. 对一个表中所有列数据模糊查询adoquery

    如何用adoquery对一个表中所有列进行模糊查询: procedure TForm3.Button4Click(Sender: TObject); var ASql,AKey: string; I: ...

  4. c#中如何使用到模糊查询

    c#中如何使用到模糊查询,先举个最简单实用的例子,可在vs控制台应用程序中输出: 定义实体类:  public class Student        {            public int ...

  5. vue中input输入第一个字符时,光标会消失,需要再次点击才能输入

    vue中input输入第一个字符时,光标会消失,需要再次点击才能输入 在这里我犯了一个小错误,v-if语法比较倾向于一次性操作,当input获取焦点时,v-if判断为true,立即刷新数据,进行渲染, ...

  6. 微信小程序优化:实现picker组件中input输入框禁止输入,而只能通过picker组件选择日期

    原来的代码如下: <view class="right">     <picker mode="date" value="{{mat ...

  7. ext.net中ComboBox空间实现模糊查询

    ComboBox中的属性添加Mode="Local"可以实现第一个字的模糊查询但是搜索中间的字无法实现 现提供一下方法使用正则表达式实现全模糊查询 <ext:ComboBox ...

  8. 解决Vue中文本输入框v-model双向绑定后数据不显示的问题

    前言 项目中遇到一个问题就是在Vue中双向绑定对象属性时,手动赋值属性后输入框的数据不实时更新的问题. <FormItem label="地址" prop="eve ...

  9. [转]ORACLE中Like与Instr模糊查询性能大比拼

    instr(title,'手册')>0  相当于  title like '%手册%' instr(title,'手册')=1  相当于  title like '手册%' instr(titl ...

随机推荐

  1. SDL 开发实战(四): SDL 事件处理

    在前面学习SDL的例子运行时,我们发现我们的窗口只停留了几秒,但是如果设置更长时间显然也有其他的弊端. 那么有没有一种好的办法可以解决这个问题呢?例如:能不能让窗口一直显示,直到检测到用户用鼠标点击关 ...

  2. [Swift]LeetCode389. 找不同 | Find the Difference

    Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...

  3. [Swift]LeetCode968.监控二叉树 | Binary Tree Cameras

    Given a binary tree, we install cameras on the nodes of the tree. Each camera at a node can monitor  ...

  4. Kubernetes---Pod的扩容和缩容

    用RC的Scale机制来实现Pod的扩容和缩容 把redis-slave的pod扩展到3个  ,  kubectl scale rc redis-slave --replicas=3 现在来缩容,把 ...

  5. [BASH]获取执行脚本的路径

    SCRIPT=$(readlink -f "$0") #当前执行脚本的真实路径,兼容软链接 basedir=$(dirname "$SCRIPT") #当前执行 ...

  6. 洛谷P1036选数(素数+组合数)

    题目链接:https://www.luogu.org/problemnew/show/P1036 主要考两个知识点:判断一个数是否为素数.从n个数中选出m个数的组合 判断一个数是否为素数: 素数一定是 ...

  7. [Abp 源码分析]六、工作单元的实现

    0.简介 在 Abp 框架内部实现了工作单元,在这里讲解一下,什么是工作单元? Unit Of Work(工作单元)模式用来维护一个由已经被业务事物修改(增加.删除或更新)的业务对象组成的列表.Uni ...

  8. Python内置函数(14)——delattr

    英文文档: delattr(object, name) This is a relative of setattr(). The arguments are an object and a strin ...

  9. 获取model的自定义特性

    class Program { static void Main(String[] args) { var t = typeof(A); var pName = t.GetProperty(" ...

  10. 8分钟学会使用AutoMapper

    一.什么是AutoMapper与为什么用它. 它是一种对象与对象之间的映射器,让AutoMapper有意思的就是在于它提供了一些将类型A映射到类型B这种无聊的实例,只要B遵循AutoMapper已经建 ...