gpt4 book ai didi

vue.js - 我如何在 Vuejs 和 Vuetify 的 lazyload 上延迟加载项目列表?

转载 作者:行者123 更新时间:2023-12-05 08:18:12 25 4
gpt4 key购买 nike

我试图制作一个无限滚动列表,但它真的不是延迟加载,坚持了几个小时,整个列表都会进来。

      .....
<v-col
v-for="(post, i) in posts"
:key="i"
cols="12"
>
<v-lazy
v-model="isActive"
:options="{
threshold: .5
}"
transition="fade-transition"
>
{{Content here}}
</....

用于测试的 API:https://jsonplaceholder.typicode.com/posts

最佳答案

有一个新的 virtual-scroller 组件,但它不适用于网格行/列等响应式内容。而是使用 v-lazy...

我发现列需要定义最小高度(大约为卡片的预期高度),以便 v-lazy 交集观察器工作。使用类似 v-sheetv-responsive 的东西来设置 min-height 并包含卡片。

同时将v-lazyv-model绑定(bind)到每个post(即:post.isActive),而不是一个全局的isActive 变量...

        <v-col lg="3" md="4" sm="6" cols="12" v-for="(post, index) in posts">
<v-sheet min-height="250" class="fill-height" color="transparent">
<v-lazy
v-model="post.isActive" :options="{
threshold: .5
}"
class="fill-height">
<v-card class="fill-height" hover>
<v-card-text>
<v-row :key="index" @click="">
<v-col sm="10" cols="12" class="text-sm-left text-center">
#{{ (index+1) }}
<h2 v-html="post.title"></h2>
<div v-html="post.body"></div>
</v-col>
</v-row>
</v-card-text>
</v-card>
</v-lazy>
</v-sheet>
</v-col>


演示:https://codeply.com/p/eOZKk873AJ

关于vue.js - 我如何在 Vuejs 和 Vuetify 的 lazyload 上延迟加载项目列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61643640/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com