scroll-view 中scroll-left问题
发布于 6 年前 作者 fhou 4605 次浏览 来自 问答

在给里面元素view设置padding值的情况下,scoll-left=scroll-view.width-循环最后的一个view的宽度,并不能准确定位到-自动滑动到最后一个view

2 回复

找到原来了,在onshow的时候得动态设置,

let than = this;

let query = wx.createSelectorQuery();

query.select(’#pkSession’).boundingClientRect(function (rect) {

let sTotal = rect.width

let index = than.data.ratingInfo.totalScore.relationGameIds.length - 1;

wx.createSelectorQuery().select(’#itemSession_’ +index).boundingClientRect(function (rect1) {

let s1 = rect1.width;

let s2 = sTotal - s1;

than.setData({

sessionScrollLeft: s2

})

}).exec()

}).exec();

但是我以这种方式,设置宽度,宽度不一致

回到顶部