【问题标题】:vue-tables-2 filtering arguments passed from parent componentvue-tables-2 过滤从父组件传递的参数
【发布时间】:2019-04-03 15:15:17
【问题描述】:

是否可以在外部对 vue-tables-2 中的客户端表使用默认过滤?

我有一个包含多个 vue 表的父组件,并且希望能够将一个字符串从父组件传递给所有子组件,每个子组件都包含一个 vue 表的实例。

【问题讨论】:

  • 请分享你的一些代码

标签: vue.js vuejs2 vue-tables-2


【解决方案1】:

由于试图保留所有逻辑客户端,我想我将在原始表数据和 vue 表之间创建一个层,并将我的逻辑应用为计算函数。

编辑-它起作用了。

这是我为计算部分所做的

computed: {
        searchRows: function () {
            var filteredRows = this.rows;
            var term = this.searchTerm;
            if(this.searchTerm) {
                filteredRows = [];
                this.rows.forEach(function(entry) {
                    if(String(entry.id).includes(term) || String(entry.name).includes(term)) {
                        filteredRows.push(entry);
                    }
                });
            }
            return filteredRows;
        }
    },

我将表上的数据链接到计算的调用。

<v-client-table :columns="columns" :data="searchRows" :options="options">

我能看到的唯一缺点是,如果表变得足够大,可能会导致问题,因为现在我在内存中最多存储了 2 个副本。

【讨论】:

    猜你喜欢
    • 2020-08-14
    • 2018-04-18
    • 2018-12-02
    • 2020-07-26
    • 2018-05-04
    • 2020-07-17
    • 1970-01-01
    • 2020-09-25
    • 2017-10-20
    相关资源
    最近更新 更多