JS部分
search: '',
systManage: [
{
type: "未知",
source: "数据库",
operation: "系统管理",
content: "查看了系统管理",
hot: "192.168.110",
time: "2017/12/05"
},
computed:{
searchData:function(){
var search =this.search;
if(search){
return this.systManage.filter(function(pro){
return Object.keys(pro).some(function(key){
return String(pro[key]).toLowerCase().indexOf(search)>-1
})
})
}
return this.systManage;
}
}
htnl 部分
<el-input placeholder="请输入搜索内容" v-model="search" style="width: 300px;">
<template slot="append">
<el-button slot="append" icon="el-icon-search"></el-button>
</template>
</el-input>
input 搜索框 要绑定v-model="search"这个变量.
其中 systManage是你的数据变量名。
在渲染 时候,将v-for="(data,index) in systManage"改为(data,index) in searchData 即可。