computed: {
//数据筛选
searchData: function () {
let search = this.searchValue;
//console.log(this.nodeList);
if (search) {
return this.nodeList.filter(function (product) {
return Object.keys(product).some(function (key) {
//这里注意全部全部转换为小写以后搜索的内容也要全部转为小写
return String(product[key]).toLowerCase().indexOf(search.toLowerCase()) > -1
})
})
}
return this.nodeList;
},
有兴趣的朋友可以去看我的源代码
https://github.com/nuls-io/explorer_2.0

本文介绍了一种在前端应用中实现数据筛选和搜索的方法,通过将搜索字符串转换为小写并应用于所有产品键值,提高了搜索功能的效率和准确性。

被折叠的 条评论
为什么被折叠?



