前端实现多个筛选项,并模糊查询

    //表格数据
      table_data: [],
      //查询条件
      form: {
        name: "",
        phone: "",
      },
      //新数组
      tableList: [],



  search() {
      let arr = this.table_data;
      Object.keys(this.form).forEach((e) => {
        arr = this.filterFunc(this.form[e], e, arr);
      });

      this.tableList = arr;
    },
  filterFunc(val, target, filterArr) {
      if (val == undefined || val == "") return filterArr;

      return filterArr.filter((p) => p[target].indexOf(val) > -1);
    },

你可能感兴趣的:(vue.js,前端)