首页 > 解决方案 > 如何在 JSON api 调用(Lazyload、Vuejs、Laravel)上应用过滤器组件

问题描述

我有一个包含一些过滤器组件的表格,并获取到我的 laravel 后端以咳出数据。我目前拥有的是过滤器函数应用于前端的表数据,但我的同事刚刚告诉我,我们将有一百万条记录,所以它必须得到延迟加载,所以它只加载可见的记录.

我不知道要寻找什么,“vue lazyload api call”没有显示我在 Google 上寻找的内容。


我对 laravel 数据库的 fetch 调用:

       getCoinRecords(api_url) {
            api_url = api_url || '/api/support/list';
            fetch(api_url)
                .then(response => response.json())
                .then(response => {
                    this.coins = response.data;
                })
        },
        

我的Vue过滤器功能:

 data() {
    return {
        coins: [],
        filterResult: {},
    }
},
computed: {
    dynFilter(){
        let items = this.coins;
            for (const [key, value] of Object.entries(this.filterResult)) {
                if(value != ""){
                    items = items.filter(coin =>{
                        if (coin[key] == value){
                            return coin[key];
                        }
                    })
                }
            }
        return items;
    },
}

标签: laravelvue.js

解决方案


推荐阅读