关键是设置scroll事件及赋值时要是延迟的,放在$nextTick或setTimeout
<scroll-view class="scroll_content" scroll-y="true" :scrollTop='scrollTop' @scroll='scroll'
:style="{'top': listTop+'px',height:taskStatus===1?scrollHeight+'px':scrollHeight2+'px'}">
<!-- 任务tab内容 -->
<TaskInfo :taskInfos='taskInfo' v-show="currentTab==='task'"></TaskInfo>
<!-- 反馈tab内容 -->
<view v-show="currentTab==='feedback'" style="display:flex;padding-bottom: 24rpx;">
<TaskFeedBack ref='feedbackRef' :taskId='taskId' @processClick='handleProcessClick'></TaskFeedBack>
</view>
<!-- 资源tab内容 -->
<TaskResource :taskId='taskId' ref="treeRef" :eventCode='eventCode' :stageId='stageId'
v-show="currentTab==='resource'"></TaskResource>
</scroll-view>
data(){
rerurn{
scrollTop:0,
oldScrollTop:0,
}
}
scroll(e){
this.oldScrollTop = e.detail.scrollTop;
},
//切换tab
handleClickSegment(e) {
this.currentTab = e.value;
this.scrollTop = this.oldScrollTop;
setTimeout(() => {
this.scrollTop=0
},100)
},