yuyuko
yuyuko
  • 发布:2020-08-05 10:57
  • 更新:2020-12-10 20:11
  • 阅读:2535

app端uni.pageScrollTo设置scrollTop无效

分类:uni-app
tj(id) {  
    let that = this;  
    // console.log(that.windowheight)  
    let target = uni.createSelectorQuery().in(this).select(id);  
    target.boundingClientRect(function(res) {  
    let x = that.dctop + res.top - (that.windowheight / 3);  
    uni.pageScrollTo({  
      duration: 0,  
      scrollTop: x  

    });  
    }).exec();  
}  

h5端没有问题,在模拟器上运行无论是设置scrollTop为数字还是变量,都只会回到顶部。

2020-08-05 10:57 负责人:无 分享
已邀请:
duyisu

duyisu

uni-page-wrapper{
height:auto!important;
}
通过加这个样式解决

不想起昵称

不想起昵称 - 没啥介绍

同问,请问你这个解决了么

不想起昵称

不想起昵称 - 没啥介绍

解决方案:查看页面中定位容器,定位脱离文档流,使用transform: translate替换定位,问题就解决了

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