滚动到一定高度吸顶

 

<view class="tabs" :class="temp == 1 ? 'tabClass' : ''"></view>
<scroll-view scroll-y="true" @scrolltolower="onLoadMore" :class="temp == 1 ? 'scroll' : ''">
    <view class="data-list" v-if="datalist && datalist.length != 0" :class="temp == 1 ? 'scrollList' : ''">
        <view class="data-ul" v-for="(item, index) in datalist"
              :key="index">
    </view>
</scroll-view>

data() {
    return {
        datalist:[],
        temp: 0,
        myScroll: 615, // 根据页面滚动设置
    }
}

onLoad() {
    uni.createSelectorQuery().select('.tabbarIndex-contents').boundingClientRect(res => {
        this.myScroll = res.top;
    }).exec();
}, 

onPageScroll(e) {
    if (e.scrollTop > this.myScroll) {
        this.temp = 1
    } else {
        this.temp = 0
    }
 },

methods:{
    onLoadMore() {
        if (this.paraModel.pageCount > this.paraModel.pageIndex) {
            this.paraModel.pageIndex++
            this.getList()
        }
    },
}

<style lang="scss" scoped>
.tabClass {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9;
  background: #fff;
  height: 100rpx;
}

.scroll {
  margin-top: 200rpx;
}

.scrollList {
  height: 100vh;
}
</style>

  

 

posted @ 2025-06-26 16:38  挽你手  阅读(13)  评论(0)    收藏  举报