• js瀑布流触底动态加载数据


    <template>
    <div class="box" ref="box" @mousewheel="onScrollEvent">
    <div class="boxItemStyle" v-for="(userTag, i) in dataSource" :key="i" ref="boxItemStyle"> <a-tag class="moreStyle" @click="more(userTag.primaryParam)"> 更多></a-tag> <div v-for="item in userTag.userTag" :key="item.code"> <p> <span style="text-align: left"> {{ item.name }}:</span> <span style="text-align: right">{{ item.value }}</span> </p> </div> </div> </div> </template> export default { data(){ return { isReachBottom: false, reachBottomDistance: 100 } }, methods: { onScrollEvent () { let scrollTop = this.$refs.box.scrollTop let scrollHeight = this.$refs.box.scrollHeight let offsetHeight = Math.ceil(this.$refs.box.getBoundingClientRect().height) let currentHeight = scrollTop + offsetHeight + this.reachBottomDistance if (currentHeight < scrollHeight && this.isReachBottom) { this.isReachBottom = false } if (this.isReachBottom) { return } if (currentHeight >= scrollHeight) { this.isReachBottom = true this.loading = true if (this.ipagination.current == 1) { this.ipagination.current += 1 } let param = {} param['pageNo'] = this.ipagination.current param['pageSize'] = this.ipagination.pageSize param['portraitId'] = this.portraitId postAction(this.url.list, { ...param }).then((res) => { this.loading = false if (res.success) { this.isScroll = res.result.records this.dataSource = this.dataSource.concat(res.result.records || res.result) this.waterFall(); } }) this.ipagination.current++ } } } }
    请用今天的努力,让明天没有遗憾。
  • 相关阅读:
    oracle 的exists 的用法
    linux
    C++纯虚函数
    C++ 的虚析构函数
    C++ new
    C++点和箭头操作符用法区别
    static
    关于C的int
    互斥量mutex的简单使用
    nginx服务器屏蔽上游错误码
  • 原文地址:https://www.cnblogs.com/cupid10/p/15291751.html
Copyright © 2020-2023  润新知