<template>
<div>
<input type="text" v-model="searchId" placeholder="搜索">
<table class="tab">
<tr>
<th>序号</th>
<th>名字</th>
<th>时间</th>
<th>操作</th>
</tr>
<tr v-for="(item,index) in newlist" :key="index">
<td>{{item.id}}</td>
<td>{{item.name}}</td>
<td>{{item.ctime}}</td>
<td><a href="#" @click="dele(index)">删除{{index}}</a></td>
</tr>
17    <!-- <tr v-if="list.length===0"><td colspan="4">已经没有数据了,请添加数据吧 123</td></tr> -->
     </table>
</div>
</template> <script>
export default {
data () {
return {
searchId:"",
list:[
{id:1,name:"cc",ctime:new Date()},
{id:2,name:"zs",ctime:new Date()},
{id:3,name:"ss",ctime:new Date()}
],
}
},
computed:{
newlist(){
//1. 常规做法
// var that=this
// function iscontainer(value){
// return value.name.indexOf(that.searchId)!==-1
// }
// var temlist=this.list.filter(iscontainer)
// iscontainer是一个函数,value就是list中的每一项的值,通过判断是否包含来来过滤数据内容
// return temlist
// }
//2.es6做法
return this.list.filter(value=>value.name.indexOf(this.searchId)!==-1) }
}
}
</script> <style> </style>

vue 中的通过搜索框进行数据过滤的过程的更多相关文章

  1. 在BootStrap的modal中使用Select2搜索框无法输入

    用modal来show一个对话框 dialog.modal({ backdrop:true, keyboard:true, show:true }); 1 2 3 4 5 然后再modal中初始化se ...

  2. Vue中计算属性、侦听、过滤、自定义指令、ref的操作

    1.计算属性 <div id="app"> <input type="text" v-model="x"> < ...

  3. 在vue中引入layer弹框的简易方法

    npm i --save layui-layer 2.在main.js中引入 import layer from "layui-layer"; 3.然后就可以在各个组件中使用lay ...

  4. Vue中使用watch来监听数据变化

    写法一: methods:{ //监听isMD upProp(){ if(this.isMD){//如果isMD等于true 就把storeManagerName赋值给isStoreManagerNa ...

  5. 040——VUE中组件之组件间的数据参props的使用实例操作

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. vue中使用axios进行ajax请求数据(跨域配置)

    npm安装axios npm install axios --save 引入axios import axios from 'axios' 使用axios mounted () { this.getH ...

  7. vue中使用watch函数,当数据改变时自动引发事件

    本来我的需求是这样的,使用ElementUI的日期选择器,当日期选择器被更改时需要根据新日期来向服务器获取新数据,但是发现这个日期选择器没有change事件,后来终于发现vue有个watch函数就是用 ...

  8. vue自定义公共组件components||在vue中,解决修改后的数据不能渲染到dom上的bug

    //主页面框架用来嵌入:Main.vue <el-col :span="24" > * { margin: 0; padding: 0; } html { width: ...

  9. vue 中使用 Toast弹框

    import { ToastPlugin,ConfirmPlugin,AlertPlugin} from 'vux' Vue.use(ToastPlugin) Vue.use(ConfirmPlugi ...

随机推荐

  1. 折腾Java设计模式之建造者模式

    博文原址:折腾Java设计模式之建造者模式 建造者模式 Separate the construction of a complex object from its representation, a ...

  2. Web 性能优化:Preload与Prefetch的使用及在 Chrome 中的优先级

    摘要: 理解Preload与Prefetch. 原文:Web 性能优化:Preload,Prefetch的使用及在 Chrome 中的优先级 作者:前端小智 Fundebug经授权转载,版权归原作者所 ...

  3. Android为TV端助力之Webview与JS双向交互

    package com.hhzt.iptv.adservice; import android.app.Activity;import android.graphics.Bitmap;import a ...

  4. 使用pyton在本地指定目录模拟服务器

    1.cd 到指定目录 2.运行命令 python 3之前 python -m SimpleHTTPServer & python 3+ python -m http.server & ...

  5. python内存回收的问题

    python实际上,对于占用很大内存的对象,并不会马上释放. 举例,a=range(10000*10000),会发现内存飙升一个多G,del a 或者a=[]都不能将内存降下来.. del 可以删除多 ...

  6. 分布式系统CAP理论

    在单机的数据库系统之中,我们很容易实现一套满足ACID 特性的 事务处理系统, 事务的一致性不存在问题. 但是在分布式系统之中,由于数据分布在不同的主机结点上,如何对着些数据进行分布式的事务处理就具有 ...

  7. Chrome 清除当前网站下的缓存

    打开开发者工具(F12),选择 Network--Disable cache 即可.需要清除某网站缓存时 F12 打开开发者工具就会自动清除这个网站的缓存,而不必清除所有网站的缓存了. 如评论中大佬所 ...

  8. 应用wavesurfer.js绘制音频波形图小白极速上手总结

    一.简介 1.1  引   人生中第一份工作公司有语音识别业务,需要做一个web网页来整合语音引擎的标注结果和错误率等参数,并提供人工比对的语音标注功能(功能类似于TranscriberAG等),(博 ...

  9. Linux命令大杂烩

    查看linux出口IP curl ifconfig.me scp跨服务器转移文件命令 scp 文件 root@IP:/application/apache-tomcat-8.0.36      回车, ...

  10. zabbix proxy

    ProxyMode=0 Server=zabbix-server的IPHostname=zabbix proxy(跟在zabbixWED网页建立代理proxies名称一样) LogFile=/data ...