惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
IT之家
IT之家
B
Blog RSS Feed
罗磊的独立博客
GbyAI
GbyAI
博客园 - Franky
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
N
Netflix TechBlog - Medium
博客园 - 三生石上(FineUI控件)
人人都是产品经理
人人都是产品经理
U
Unit 42
博客园 - 叶小钗
Jina AI
Jina AI
MyScale Blog
MyScale Blog
雷峰网
雷峰网
B
Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
Recent Announcements
Recent Announcements
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - 赵瑛

如何把一个js的代码变成一个.min.js的文件 thinkphp8有一个木马文件链接 thinkphp 可以居中的分页css样式 thinkphp8无法显示验证码的原因之一 php将内容转为word vue点击复制 vue简单分页 mpdf增加字体并进行使用 jquery导出word css清除浮动最好的方法 Elasticsearch同时实现and与or查询 Elasticsearch查询指定字段是否有重复数据 查询并删除Elasticsearch库中指定字段重复的数据 elasticsearch进行and,or多条件组合查询 elasticsearch中的and和or php FTP操作类( 拷贝、移动、删除文件/创建目录 ) mysql重置自增id js 双指放大、拖动图片 php操作elasticsearch数据库的方法
vue无限加载
赵瑛 · 2024-07-11 · via 博客园 - 赵瑛
    const app = {
        data() {
            return {
                info: [], // 存储题目详情数组
                currentPage: 1, // 当前页码
                pageSize: 3, // 每页显示的题目数量
                sjid: sjid, // 注意:这里假设sjid已经定义
                isLoading: false, // 是否正在加载数据
                hasMore: true // 是否有更多数据可以加载
            };
        },
        methods: {
            fetchData(page = 1) {
                if (this.isLoading || !this.hasMore) return; // 如果正在加载或没有更多数据,则不执行

                this.isLoading = true;
                axios
                    .get('/api/shijuan/timu_list.html', {
                        params: {
                            p: page,
                            limit: this.pageSize,
                            sjid: this.sjid
                        }
                    })
                    .then(response => {
                        if (response.data.data.length === 0) {
                            this.hasMore = false; // 如果没有返回数据,则认为没有更多数据
                        } else {
                            this.info = this.info.concat(response.data.data); // 合并数据
                            this.currentPage = response.data.p; // 更新当前页码(如果API返回了当前页码)
                        }
                        this.isLoading = false;
                    })
                    .catch(error => {
                        console.error('Error fetching data:', error);
                        this.isLoading = false;
                    });
            },
            handleScroll() {
                const windowHeight = window.innerHeight;
                const scrollPosition = window.scrollY + windowHeight;
                const documentHeight = document.documentElement.offsetHeight;

                if (scrollPosition >= documentHeight - 100 && !this.isLoading && this.hasMore) {
                    // 当滚动到页面底部时加载更多数据
                    this.fetchData(this.currentPage);
                }
            }
        },
        mounted() {
            this.fetchData(this.currentPage);
            window.addEventListener('scroll', this.handleScroll);
        },
        beforeUnmount() {
            // 组件销毁前移除事件监听器
            window.removeEventListener('scroll', this.handleScroll);
        }
    };
    Vue.createApp(app).mount('#app');
    <div class="am-list-news-bd" id="app" @scroll="handleScroll">
        <ul class="am-list yulan-box">
            <li class="am-g  questions-box" v-for="site in info">
                <a :href="'http://yy.t.ihwrm.com/index/shijuan/timu_info.html?sjid='+site.sjid+'&tmid='+site.tmid" class="am-list-item-hd">

                    <p class="question clearfix">
                        <span class="q-type" style="margin-top:3px;">{{ site.tx_name }}</span>
                        <span class="question-tit">
                            <span class="red"></span>
                            {{ site.tigan }}
                        </span>
                    </p>
                </a>
                <span class="am-list-date">{{ site.datetime }}</span>
            </li>
        </ul>
        <!-- 加载更多提示 -->
        <div v-if="isLoading" class="loading">加载中...</div>
        <!-- 底部边界,用于触发加载 -->
        <div ref="bottomBoundary" style="height: 50px;"></div>
    </div>