1***@qq.com
1***@qq.com
  • 发布:2025-05-30 14:25
  • 更新:2025-06-24 15:39
  • 阅读:80

【报Bug】小程序scroll-view在苹果手机会自动触底

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 4.24

第三方开发者工具版本号: 1.06.2503281

基础库版本号: 3.8.1

项目创建方式: HBuilderX

示例代码:

<scroll-view scroll-y style="height: 100%" scroll-anchoring scroll-with-animation enable-back-to-top
refresher-enabled :refresher-threshold="100" :refresher-triggered="isRefresher"
@refresherrefresh="onRefresherrefresh" :lower-threshold="200" @scrolltolower="getMoreList"></scroll-view>

操作步骤:

苹果手机,进入列表页面,视图会停留在第一页最后的列表数据,然后会自动加载第二页

预期结果:

进入列表页面,滚动条应该在最顶部并且只加载第一页数据

实际结果:

进入列表页面,会自动滚动到第一页最后一条数据并且加载了第二页数据

bug描述:

列表中使用scroll-view,滚动触底会加载下一页,但是在苹果手机上一进入页面没有手动滚动,但是会自动触底加载下一页

2025-05-30 14:25 负责人:无 分享
已邀请:
DCloud_UNI_JBB

DCloud_UNI_JBB

使用原生微信小程序有此问题吗?有的话可以反馈到微信社区,没有麻烦发个可复现demo

  • 1***@qq.com (作者)

    在微信开发工具上没有这个问题,但是用苹果手机预览就会复现

    2025-07-16 15:40

  • 1***@qq.com (作者)

    <template>

    <view class="release boxs">

    <view class="release-top">

    <search-view @changeInput='searchEvent'></search-view>

    </view>

    <view class="release-main">

    <view class="release-cons boxs">

    <scroll-view scroll-y="true" style="height: 100%" scroll-anchoring scroll-with-animation

    enable-back-to-top refresher-enabled :refresher-threshold="100" :refresher-triggered="isRefresher"

    @refresherrefresh="onRefresherrefresh" :lower-threshold="200" @scrolltolower="getMoreList">

    <view class="release-cons-list boxs" v-for="(item,index) in communiteList" :key="index"

    @click="gotoDe(item)">

    <view class="list-title yd-flex-h-hS-vC">

    <view class="list-title-l yd-flex-h-hL-vC">

    <text class="span yd-clamp-1">{{item.subjectName}}</text>

    <text class="title yd-clamp-1">{{item.title}}</text>

    </view>

    <view class="list-title-r yd-flex-h-hC-vC" @click.stop="openPopup(item)"

    v-if="hasPer(['publish:info:remove'])">

    <i class="iconfont LTa-19"></i>

    </view>

    </view>

    <view class="list-content yd-clamp-4">

    {{$globalMethod.stripHtmlTags(item.content)}}

    </view>

    <view class="list-text">

    <text class="text1 boxs yd-clamp-1">{{item.companyName}}</text>

    <text class="yd-clamp-1" v-if="item.createBy">{{item.createBy}}</text>

    <text

    class="yd-clamp-1">{{$globalMethod.arrayLookup(staticData.user_identity,'value',item.createByIdentity,'label')}}</text>

    </view>

    <view class="list-last yd-flex-h-hS-vC">

    <view class="list-last-l yd-flex-h-hL-vC">

    <view class="yd-flex-h-hL-vC l-li">

    阅读

    <text class="l-li-text">{{item.browseNum}}</text>

    </view>

    <view class="yd-flex-h-hL-vC l-li">

    转发

    <text>{{item.transferNum}}</text>

    </view>

    <view class="yd-flex-h-hL-vC l-li">

    评论

    <text>{{item.commentCount}}</text>

    </view>

    </view>

    <view class="list-last-r yd-flex-h-hR-vC">

    {{item.createTime}}

    </view>

    </view>

    </view>

    <no-list v-if="communiteList.length <=0 && loadStatus != 'loading'"></no-list>

    <view style="padding: 20rpx 0 50rpx" v-else>

    <u-loadmore fontSize="28rpx" iconSize="17px" line :status="loadStatus" />

    </view>

    </scroll-view>

    </view>

    <!-- 发布按钮 -->

    <view class="low-btn" @click="gotoAddPublish" v-if="hasPer(['publish:info:add'])">

    <view class="yd-flex-v-hC-vC" style="width: 100%; height: 100%;">

    <i class="iconfont LTa-11"></i>

    <text>发布</text>

    </view>

    </view>


        </view>  
    <release-popup-vue ref="releasePopupVue" @deleteEvent="deleteEvent"></release-popup-vue>
    </view>

    </template>


    <script>

    import {

    getPublishListAPI,

    getPublishCountAPI,

    deletePublishAPI

    } from '@/api/index/publish.js'

    import {

    getMinePublishsAPI,

    getOwnPublishCountAPI

    } from '@/api/index/mine.js'

    import searchView from '@/components/search/index.vue';

    import releasePopupVue from './components/releasePopup.vue';

    import {

    useGetDictData

    } from '@/utils'

    const dictTypeList = ['user_identity']


    export default {  
    components: {
    searchView,
    releasePopupVue
    },
    data() {
    return {
    type: 0,
    communiteList: [],
    loadStatus: 'loading',
    total: 0,
    isRefresher: false, // scroll-view 下拉刷新状态
    params: {
    pageSize: 10,
    pageNum: 1,
    keyWord: '',
    isViolation: 0
    },
    plateType: 1,
    currentId: '',
    staticData: [],
    }
    },
    onLoad(param) {
    this.type = 0; //0是发布管理,1是我的发布
    if (param && param.type == 1) {
    this.type = 1;
    uni.setNavigationBarTitle({
    title: '我的发布'
    })
    }
    this.initialDataEvent()
    },
    methods: {
    async initialDataEvent() {
    this.staticData = {
    ...this.staticData,
    ...(await useGetDictData(...dictTypeList)),
    }
    this.getDefaultData()
    this.getDefaultEvent()
    },
    //发布管理-公司信息
    getList() {
    this.loadStatus = 'loading'
    const data = {
    ...this.params,
    terminal: 'management'
    }
    getPublishListAPI(data).then(res => {
    if (res.code !== 200) {
    this.loadStatus = 'nomore'
    return
    }
    this.communiteList = [...this.communiteList, ...res.rows]
    this.total = res.total
    this.loadStatus =
    res.total > this.params.pageNum * this.params.pageSize ? 'loadmore' : 'nomore'
    }).catch(() => {
    this.loadStatus = 'nomore'
    })
    },
    getDefaultData() {
    this.params.pageNum = 1;
    this.params.pageSize = 10;
    this.communiteList = []
    },
    /**
    * scroll-view 触发下拉刷新
    */
    async onRefresherrefresh() {
    this.isRefresher = true
    this.getDefaultData()
    await this.getDefaultEvent()
    this.isRefresher = false
    },
    // 加载更多
    getMoreList() {
    if (
    this.total > this.communiteList.length &&
    this.params.pageNum <
    Math.ceil(this.total / this.params.pageSize)
    ) {
    this.params.pageNum++;
    this.getDefaultEvent()
    }
    },
    openPopup(item) {
    this.currentId = item.publishId
    this.$refs.releasePopupVue.open()
    },
    // 删除
    deleteEvent() {
    uni.showModal({
    title: '温馨提示',
    content: '执行删除操作后,该数据将被移除,请确认是否删除?',
    cancelText: '取消',
    confirmText: '确定',
    success: res => {
    if (res.confirm) {
    this.deletePublishEvent()
    }
    },
    })

    },
    deletePublishEvent() {
    deletePublishAPI(this.currentId).then(res => {
    if (res.code == 200) {
    this.initialDataEvent()
    }
    })
    },
    searchEvent(val) {
    this.params.keyWord = val;
    this.getDefaultData()
    this.getDefaultEvent()
    },
    getDefaultEvent() {
    this.plateType = 2
    if (this.type == 0) {
    this.getList()
    } else {
    this.getMinePublishsEvent()
    }
    },
    gotoDe(item) {
    uni.navigateTo({
    url: '/pages/specialCommittee/specialComDe?id=' + item.publishId
    })
    },
    // 个人发布
    getMinePublishsEvent() {
    this.loadStatus = 'loading'
    getMinePublishsAPI(this.params).then(res => {
    if (res.code !== 200) {
    this.loadStatus = 'nomore'
    return
    }
    this.communiteList = [...this.communiteList, ...res.rows]
    this.total = res.total
    this.loadStatus =
    res.total > this.params.pageNum * this.params.pageSize ? 'loadmore' : 'nomore'
    }).catch(() => {
    this.loadStatus = 'nomore'
    })
    },
    gotoAddPublish() {
    uni.navigateTo({
    url: `/pages/specialCommittee/addPublish?plateType=${this.plateType}&subjectId=`
    })
    }
    }
    }

    </script>


    <style scoped lang="less">

    .release {

    width: 100%;

    height: 100vh;


        &-top {  
    padding: 24rpx;
    padding-top: 20rpx;
    height: 88rpx;
    background: #D80C18;
    }

    &-main {
    width: 100%;
    height: calc(100% - 123rpx);
    position: relative;
    top: -10rpx;
    background: #f5f5f5;
    }

    &-main1 {
    height: calc(100% - 133rpx);
    position: relative;
    top: 0;
    }

    &-cons {
    width: 100%;
    height: 100%;
    padding: 24rpx;

    &-list {
    border-radius: 14rpx;
    background: #fff;
    padding: 24rpx;
    margin-bottom: 24rpx;
    box-shadow: 0 6rpx 24rpx rgba(0, 0, 0, 0.1);

    .list-title {
    &-l {
    font-size: 28rpx;
    color: #000;

    .span {
    height: 40rpx;
    line-height: 40rpx;
    text-align: center;
    border-radius: 6rpx;
    background: #ffe5e5;
    padding: 0 8rpx;
    font-size: 24rpx;
    color: #d80c18;
    margin-right: 8rpx;
    display: inline-block;
    max-width: 180rpx;
    }

    .title {
    max-width: 420rpx;
    }
    }

    &-r {
    i {
    font-size: 32rpx;
    color: #ABABAB;
    }
    }
    }

    .list-content {
    margin-top: 16rpx;
    font-size: 26rpx;
    line-height: 32rpx;
    color: #333;
    /* 控制文本换行 */
    word-wrap: break-word;
    word-break: break-all;
    white-space: pre-line;
    max-height: 128rpx;
    }

    .list-text {
    margin-top: 16rpx;
    font-size: 24rpx;
    color: #d80c18;

    text {
    margin-right: 16rpx;
    height: 40rpx;
    border-radius: 6rpx;
    background: #ffe5e5;
    line-height: 40rpx;
    padding: 0 8rpx;
    }

    text.text1 {
    background: #fff;
    border: 2rpx solid #d80c18;
    line-height: 36rpx;
    }
    }

    .list-last {
    margin-top: 20rpx;

    &-l {
    font-size: 24rpx;
    color: rgb(51, 51, 51);

    .l-li {
    min-width: 80rpx;
    padding-right: 20rpx;

    text {
    color: #333;
    margin-left: 10rpx;
    }

    text.l-li-text {
    color: rgb(216, 12, 24);
    }
    }
    }

    &-r {
    font-size: 24rpx;
    color: #ababab;
    }
    }
    }
    }
    }

    </style>

    2025-07-16 15:42

要回复问题请先登录注册