<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. 模板引擎artTemplate的使用

    1.引入template文件 <script src = js/template-native.js></script> 2.写模板 <script type=" ...

  2. npm ERR! asyncWrite is not a function

    1.背景:原先node是官网下载安装的,通过brew更新了下,然后到项目里npm i 安装包时候,报错2.解决:卸载官网下载安装的node,重装 sudo rm -rf /usr/local/{bin ...

  3. 基于.net EF6 MVC5+WEB Api 的Web系统框架总结(1)-Web前端页面

    本 Web 系统框架基于C# EF6+MVC+WebApi的快速应用开发平台.本节主要介绍Web前端页面设计与实现.Web前端页面主要分为普通列表页面.树状导航列表页面.普通编辑页面.数据导入页面.向 ...

  4. MyDAL - .Where() 之 .WhereSegment 根据条件 动态设置 Select查询条件 使用

    索引: 目录索引 一.API 列表 1.WhereSegment 属性,指示 根据条件 动态拼接 where 查询过滤条件 见如下示例. 二.API 单表-完整 方法 举例 // 上下文条件 变量 v ...

  5. shell 中 if then语句中会跟着-ne -ge之类的参数的含义

    if [ 1 -ne 1 ];then...fi这是指当1不等于1时执行then后的语句 -eq:等于-ne:不等于-le:小于等于-ge:大于等于-lt:小于-gt:大于

  6. SQLServer之创建事务序列化

    创建事务序列化注意事项 语法:set transaction isolation level serialize; 序列化会指定下列内容: 语句不能读取已由其他事务修改但尚未提交的数据. 任何其他事务 ...

  7. C# -- 使用 DriveInfo 获取磁盘驱动器信息

    C# -- 使用 DriveInfo 获取磁盘驱动器信息 1. 代码实现 class Program { static void Main(string[] args) { GetComputerDi ...

  8. mybatis常见错误

    1.传入单个参数为list时 List<Objects> query(@param("list") List<String> list) <selec ...

  9. 逆向学习-Upack的PE文见头分析

    重叠文件头 MZ文件头与PE文件头重叠. offest 0 e_magic:magic number = 4D5A('MZ') offest 3C  e_lfanew:File address of ...

  10. Swing 混合布局

    案例一:Border边境边界 package swing; /** * swing 混合布局 */ import java.awt.*; import javax.swing.*; public cl ...