在vue-js数据表组件中进行过滤的问题

时间:2017-06-22 08:18:19

标签: datatables vuejs2

我将vue与以下数据表组件一起使用: https://www.npmjs.com/package/vuejs-datatable

我的组件如下:

<template>
    <div>

        <datatable
            :columns="subsystemsTable.table_columns"
            :data="subsystems"
            filterable paginate
        ></datatable>

    </div>
</template>

<script>

    import SingleSubsystem from './SingleSubsystem.vue';


    export default {

        created() {
            this.showSubsystems();           
        },

        computed: {
            subsystems() {
                return this.$store.state.subsystemsArray;
            }
        },

        data() {
            return {
                subsystemsTable: {
                    table_columns: [
                        {label: 'id', field: 'id'},
                        {label: 'Наименование', field: 'subsystem_name'},                        
                    ]
                }                
            }
        },

        methods: {
            showSubsystems() {
                let self = this;
                this.$store.state.gatewayService.getQueryResult({
                    this: this,
                    name: 'subsystems_list',
                    actions: {
                        success: function(response) {
                            self.$store.state.subsystemsArray = response.result;
                        }
                    }
                });
            }           
        }

    }
</script>

但由于我使用的是计算属性,因此我在控制台中收到以下警告:

[Vue warn]: Error in render function: "TypeError: rows.filter is not a function"

TypeError: rows.filter is not a function
    at Vue$3.filtered_rows (app.js:61503)
    at Watcher.get (app.js:54501)
    at Watcher.evaluate (app.js:54601)
    at Vue$3.computedGetter [as filtered_rows] (app.js:54855)
    at Vue$3.sorted_rows (app.js:61509)
    at Watcher.get (app.js:54501)
    at Watcher.evaluate (app.js:54601)
    at Vue$3.computedGetter [as sorted_rows] (app.js:54855)
    at Vue$3.visible_rows (app.js:61532)
    at Watcher.get (app.js:54501)

无论如何,一切正常,但我抓住了这些警告。如何摆脱它们。

0 个答案:

没有答案