得推网络科技
得推网络科技
  • 发布:2019-08-12 00:19
  • 更新:2019-08-12 00:19
  • 阅读:4142

uniApp中boundingClientRect多次调用会都执行

分类:uni-app
getPage: function(touserid) {  
                console.log("getPage")  
                var that = this;  
                that.app.get({  
                    url: that.app.apiHost + "/module.php?m=im_pm&touserid=" + touserid,  
                    success: function(res) {  

                        var it=setTimeout(function(){  
                            query.select('#main').boundingClientRect(function(rs) {  
                                  uni.pageScrollTo({  
                                    scrollTop:rs.height,  
                                    duration:1  
                                  })  
                                  oldHeight=rs.height;  
                                  console.log(oldHeight);  
                            }).exec();  

                        },30)  

                    }  
                })  
            },  

            getList: function() {  
                if (this.per_page == 0) return false;  
                var that = this;  
                that.loadIng = true;  
                that.app.get({  
                    url: that.app.apiHost + "/module.php?m=im_pm&touserid=" + that.touser.userid,  
                    data: {  
                        per_page: that.per_page  
                    },  
                    success: function(res) {  

                        setTimeout(function(){  
                            query.select('#main').boundingClientRect(rs => {  
                              uni.pageScrollTo({  
                                scrollTop:rs.height-oldHeight,  
                                duration:1  
                              })  
                              console.log(rs.height+" "+oldHeight)  
                             // that.oldsch=rs.height;  
                            }).exec();  
                        },30)  
                        that.loadIng = false;  
                    }  
                })  
            },

在getlist中调用boundingClientRect, 会影响getPage中的boundingClientRect,但是没有调用getPage。这样没法获取两个不同时间的元素高度。

2019-08-12 00:19 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复