laravel - 如何在 JSON api 调用(Lazyload、Vuejs、Laravel)上应用过滤器组件
问题描述
我有一个包含一些过滤器组件的表格,并获取到我的 laravel 后端以咳出数据。我目前拥有的是过滤器函数应用于前端的表数据,但我的同事刚刚告诉我,我们将有一百万条记录,所以它必须得到延迟加载,所以它只加载可见的记录.
- 如何将过滤器函数应用于 fetch api 调用?我希望数据被过滤,然后发送到 Vue。
我不知道要寻找什么,“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;
},
}
解决方案
推荐阅读
- ruby-on-rails - 在 Postman 中连接到 API 时感到困惑
- python - subprocess.CalledProcessError:为不可 ping 的目标返回非零退出状态 1
- python - 将json转换为python obj
- apache-kafka - 从 Kafka Store Changelog 读取时出现 OffsetOutOfRangeException
- amazon-web-services - AWS:Dynamo DB 首次请求具有高写入延迟
- c++ - Arduino 从 SD 卡读取最后一行
- eclipse-plugin - 相当于 Jetbrains Idea for Eclipse 的 Intentions 的代码重构插件
- c# - 带有 iframe 的弹出窗口:一次使用多个 @Html.AntiForgeryToken()
- arm - LDREX/STREX 与 Cortex M3 和 M4
- delphi - 如何在firemonkey中限制listview