el-table模糊搜索

yw3692582 / 2023-05-12 / 原文

computed: {
     // 根据ip或盒子名称进行搜索
     getSearchInfo() {
      let search = this.search
      if (search) {
       this.currpage = 1
       this.currentPage = 1
       return this.tableData.filter((data) => {
        return Object.keys(data).some((key) => {
          if(typeof data[key] == 'string'){
            return data[key].toLowerCase().indexOf(search.toLowerCase()) > -1
          }
          if (typeof data[key] == 'number') {
            return data[key].toString().includes(search)
          }
        })
       })
      }
      return this.tableData
     },
    },