VueJs中具有Bootstrap-vue的过滤方法

时间:2019-11-28 11:03:28

标签: vue.js axios bootstrap-vue

我尝试在Vue js中使用bootstrap-vue创建过滤器。 分页有效,但是当我尝试仅接收过滤的数据时,它将无法正常工作。

有什么帮助吗?

getCustomers(contextFromBootstrap) {

      if (contextFromBootstrap.filter) {
        const p = axios
        .get(`/example?page=${contextFromBootstrap.currentPage}&filter=${contextFromBootstrap.filter}`);

        return p.then(response => {
          this.perPage = response.data.per_page;
          this.currentPage = response.data.current_page;
          const i = response.data.data.match(contextFromBootstrap.filter) //Here I want to receive only filtered data
          return i || [];
        });

      } else {  
        const p = axios
          .get(`/example?page=${contextFromBootstrap.currentPage}`);

          return p.then(response => {
            this.perPage = response.data.per_page;  
            this.currentPage = response.data.current_page;  
            const i = response.data.data;
            return i || [];
          });
      }
},

0 个答案:

没有答案