最近在使用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. idea之debug

    [转载]原文地址:https://www.cnblogs.com/nihaorz/p/7613967.html 在Intellij IDEA中使用Debug Debug用来追踪代码的运行流程,通常在程 ...

  2. [Swift]LeetCode13. 罗马数字转整数 | Roman to Integer

    Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 ...

  3. [Swift]LeetCode347. 前K个高频元素 | Top K Frequent Elements

    Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [ ...

  4. 英语笔记3(git)

    备注 一: Staging Modified Files Let’s change a file that was already tracked. (tracked 表示该文件已经被git管理过,再 ...

  5. nvidia-docker+cuda8.0+ubuntu16.04

    nvidia-docker安装 如果之前安装过docker1.0版本,需要先删掉该版本和之前创建的容器 docker volume ls -q -f driver=nvidia-docker | xa ...

  6. Python内置函数(7)——bytearray

    英文文档: class bytearray([source[, encoding[, errors]]]) Return a new array of bytes. The bytearray cla ...

  7. Java核心技术及面试指南 多线程并发部分的面试题总结以及答案

    7.2.10.1有T1.T2.T3三个线程,如何保证T2在T1执行完后执行,T3在T2执行完后执行? 用join语句,在t3开始前join t2,在t2开始前join t1. 不过,这会破坏多线程的并 ...

  8. 【Maven】---Linux搭建Nexus3.X私服

    Linux搭建Nexus3.X私服 备注:linux版本: ubuntu 同时已经部署好JDK8环境 一.linux安装nexus 1.创建文件夹并进入该目录 cd /usr/local && ...

  9. HashTable与ConcurrentHashMap的区别

  10. Jenkins 集群搭建

    一.前言 Jenkins是当下比较流行的一款功能强大的持续集成工具,它支持搭建集群,来提高多项目的构建速度,模式为主从模式,master会将任务分配到各个从节点进行并发构建,从而提高速度,下面介绍一下 ...