移动端网页使用Vue实现页面分页功能

具体实现步骤:

1.为页面添加滚动监听事件 (在mounted钩子函数中添加监听事件)

 mounted: function () {

                window.addEventListener('scroll', _this.Paging); //监听页面滚动
 },

2. 在methods选项中写分页方法

methods: {
             Paging: function () {
                     if (document.documentElement.scrollHeight - document.documentElement.clientHeight == document.documentElement.scrollTop) {
                      setTimeout(this.ListQuery(), 5000);//5秒后执行查询方法
                }
         }

}

  1. document.documentElement.scrollHeight  浏览器所有内容高度
  2. document.documentElement.clientHeight  浏览器可视部分高度
  3. document.documentElement.scrollTop  浏览器滚动部分高度
  4. ListQuery() 是我自定义的查询方法,当页面滚动到低部时去查询列表的内容

     关于setTimeout(),可以点击这里了解更多

完毕!!!

猜你喜欢

转载自blog.csdn.net/liangmengbk/article/details/83893215