最近在使用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. 事件派发dispatchEvent

    1.什么是dispatchEvent? dispatch意为"调度"."派遣",event为"事件".所以dispatchEvent即向指定 ...

  2. [Swift]LeetCode242. 有效的字母异位词 | Valid Anagram

    Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: ...

  3. [Swift]LeetCode435. 无重叠区间 | Non-overlapping Intervals

    Given a collection of intervals, find the minimum number of intervals you need to remove to make the ...

  4. [Swift]LeetCode556. 下一个更大元素 III | Next Greater Element III

    Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly th ...

  5. Node.js 种子下载器

    Node.js 种子下载器 庆祝 2018 国庆,制作了一个 Node.js 的种子下载器.爬取页面,根据页面的链接,破解另外一个网站,下载种子文件.项目比较简单,爬取页面没有使用任何爬虫框架.项目源 ...

  6. Java连接数据库之SQLServer

    工具: eclipse Microsoft SQL Server SQL Server连接驱动:mssql-jdbc-6.4.0.jre8.jar SQL script代码 CREATE DATABA ...

  7. BBS论坛(十九)

    19.1.cms轮播图管理页面布局 (1)cms/cms_base.html <li class="nav-group banner-manage"><a hre ...

  8. pytorch学习:准备自己的图片数据

    图片数据一般有两种情况: 1.所有图片放在一个文件夹内,另外有一个txt文件显示标签. 2.不同类别的图片放在不同的文件夹内,文件夹就是图片的类别. 针对这两种不同的情况,数据集的准备也不相同,第一种 ...

  9. JAVA集合类兄妹List和Set

    List 接口及其实现类 有序集合,集合中每个元素都有其对应的顺序索引,类似数组,索引也是从 0 开始,可以根据元素的索引,来访问元素. List 集合允许添加相同的元素,因为它是通过下标来取值的,不 ...

  10. Content Security Policy (CSP) 介绍

    当我不经意间在 Twitter 页面 view source 后,发现了惊喜. <!DOCTYPE html> <html lang="en"> <h ...