
在计算属性中定义:
利用 filter 和 includes 过滤找寻你所寻找的数据
computed:{
// 模糊搜索
search() {
if(this.value) {
return this.tableData.filter((value) => {
return value.orgName.includes(this.value)
})
}
}
},
在 methods 中定义方法
判断输入框是否输入
sousuo1() {
if(!this.value) {
return this.tableData;
}
return this.search
},
最后

将 tabelDate 替换成我们模糊搜索的数据
本文介绍如何使用Vue.js实现表格数据的模糊搜索功能。通过在计算属性中利用filter和includes方法来过滤并查找所需数据。当用户在输入框中输入内容时,系统会实时更新显示的搜索结果。
4261





