之前用过scroll-view,发现不加scroll-top和bindscroll属性时,内部渲染数据刷新后滚动条自动回到顶部,所以做上拉加载加上了这两个属性,可今天的这个却不行了!
1、不加scroll-top和bindscroll属性(内部数据刷新后滚动条在原位)
<scroll-view id="fa">
<view class="">
<text id="con">
{{sectionCon}}
</text>
</view>
</scroll-view>
<view id="button">
<view hover-class="bt"style="border-right:1px solid #092e43" catchtap="before">上一章</view>
<view hover-class="bt" catchtap="after">下一章</view>
</view>
2、动态改变scroll-top的值(发现滚动条滚动时并未触发bindscroll,动态设置的scroll-top没作用)
<scroll-view id="fa" bindscroll="changescroll" scroll-top="{{scrollTop}}">
<view class="">
<text id="con">
{{sectionCon}}
</text>
</view>
</scroll-view>
<view id="button">
<view hover-class="bt"style="border-right:1px solid #092e43" catchtap="before">上一章</view>
<view hover-class="bt" catchtap="after">下一章</view>
</view>
before:function(){
let that = this;
...
...
...
that.setData({
sectionCon: res.data.content,
chaindex: chaindex,
scrollTop: 0
})
},
after:function(){
let that = this;
...
…
...
that.setData({
sectionCon: res.data.content,
chaindex: chaindex,
scrollTop: 0
})
},
changescroll: function (event) {
console.log("改变滚动条")
console.log(event)
this.setData({
scrollTop: event.detail.scrollTop
})
}