小程序利用scroll-view加载更多页面回到最顶部?

在写小程序的加载更多的时候会出现页面回到顶部的问题
用的是scroll-view
无论是这样写
var data = res.data.data
var listData = utils.obtain(data)
var cur = wx.getStorageSync('cur')-1
listData.forEach(e=>{

self.data.newList[cur].push(e)

})
self.setData({

[cw]: self.data.newList[cur]

})
还是
self.setData({

[cw]: self.data.newList[cur].concat(listData)

})
页面都是回到最顶部

<swiper-item wx:for="{{newList}}" wx:key="*this" wx:for-index='index'>
<scroll-view scroll-y="true" bindscrolltolower="bindDownLoad" scroll-top="500px" class="scoll-h" >
<!-- <view>{{newList[index]}}</view> -->
<view wx:for="{{newList[index]}}" wx:for-item="item" wx:key="articles" wx:for-index='articlesindex' class='newscontent'>
<template is="list" data="{{item,articlesindex}}"></template>
</view>
</scroll-view>
</swiper-item>
这是页面代码 希望有大佬能帮忙看看

阅读 5.5k
2 个回答

我们项目使用多维数组(以及对象中的数组)遍历时也遇到了这个问题,每次更新对象中的数组数据页面都会回到顶部,尝试把scroll-view 里面的列表使用一个一维数组来进行遍历的话,就没有这个问题,希望能帮到你

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题