浏览代码

scrolltop兼容

Karsa 3 年之前
父节点
当前提交
f607b26f8d
共有 2 个文件被更改,包括 5 次插入4 次删除
  1. 3 2
      src/views/hzyb/report/ChapterDetail.vue
  2. 2 2
      src/views/hzyb/report/Detail.vue

+ 3 - 2
src/views/hzyb/report/ChapterDetail.vue

@@ -274,7 +274,9 @@ export default {
 
     loadMoreHandle: _.throttle(function() {
 
-        if(document.body.scrollTop>window.outerHeight){
+        const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; // 滚动的高度
+
+        if(scrollTop>window.outerHeight){
             this.showToTop=true
         }else{
             this.showToTop=false
@@ -282,7 +284,6 @@ export default {
 
         if(this.page_no >= this.total_page) return
 
-        const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; // 滚动的高度
         const clientHeight = document.documentElement.clientHeight || document.body.clientHeight; // 可视高度
         const scrollHeight = document.body.scrollHeight; // 总高度
         const bufferHeight = 400;

+ 2 - 2
src/views/hzyb/report/Detail.vue

@@ -281,7 +281,8 @@ export default {
 
         loadMoreHandle: _.throttle(function() {
 
-            if(document.body.scrollTop>window.outerHeight){
+            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; // 滚动的高度
+            if(scrollTop>window.outerHeight){
                 this.showToTop=true
             }else{
                 this.showToTop=false
@@ -289,7 +290,6 @@ export default {
 
             if(this.page_no >= this.total_page) return
 
-            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; // 滚动的高度
             const clientHeight = document.documentElement.clientHeight || document.body.clientHeight; // 可视高度
             const scrollHeight = document.body.scrollHeight; // 总高度
             const bufferHeight = 400;