vue2 mint-ui loadmore实现下拉刷新,上拉更多功能
程序员文章站
2022-04-13 23:41:08
...
这篇文章主要介绍了vue2 mint-ui loadmore实现下拉刷新,上拉更多功能,需要的朋友可以参考下
mintui是饿了么团队针对vue开发的移动端组件库,方便实现移动端的一些功能,这里主要给大家介绍vue2 mint-ui loadmore实现下拉刷新,上拉更多功能,具体代码如下所示:
<template> <p class="page-loadmore"> <h1 class="page-title">Pull up</h1> <p class="page-loadmore-desc">在列表底部, 按住 - 上拉 - 释放可以获取更多数据</p> <p class="page-loadmore-desc">translate : {{ translate }}</p> <p class="loading-background" :style="{ transform: 'scale3d(' + moveTranslate + ',' + moveTranslate + ',1)' }"> translateScale : {{ moveTranslate }} </p> <p class="page-loadmore-wrapper" ref="wrapper" :style="{ height: wrapperHeight + 'px' }"> <mt-loadmore :top-method="loadTop" @translate-change="translateChange" @top-status-change="handleTopChange" :bottom-method="loadBottom" @bottom-status-change="handleBottomChange" :bottom-all-loaded="allLoaded" ref="loadmore"> <ul class="page-loadmore-list"> <li v-for="item in list" class="page-loadmore-listitem">{{ item }}</li> </ul> <p slot="top" class="mint-loadmore-top"> <span v-show="topStatus !== 'loading'" :class="{ 'is-rotate': topStatus === 'drop' }">↓</span> <span v-show="topStatus === 'loading'"> <mt-spinner type="snake"></mt-spinner> </span> </p> <p slot="bottom" class="mint-loadmore-bottom"> <span v-show="bottomStatus !== 'loading'" :class="{ 'is-rotate': bottomStatus === 'drop' }">↑</span> <span v-show="bottomStatus === 'loading'"> <mt-spinner type="snake"></mt-spinner> </span> </p> </mt-loadmore> </p> </p> </template> <style> .loading-background, .mint-loadmore-top span { -webkit-transition: .2s linear; transition: .2s linear } .mint-loadmore-top span { display: inline-block; vertical-align: middle } .mint-loadmore-top span.is-rotate { -webkit-transform: rotate(180deg); transform: rotate(180deg) } .page-loadmore .mint-spinner { display: inline-block; vertical-align: middle } .page-loadmore-desc { text-align: center; color: #666; padding-bottom: 5px } .page-loadmore-desc:last-of-type, .page-loadmore-listitem { border-bottom: 1px solid #eee } .page-loadmore-listitem { height: 50px; line-height: 50px; text-align: center } .page-loadmore-listitem:first-child { border-top: 1px solid #eee } .page-loadmore-wrapper { overflow: scroll } .mint-loadmore-bottom span { display: inline-block; -webkit-transition: .2s linear; transition: .2s linear; vertical-align: middle } .mint-loadmore-bottom span.is-rotate { -webkit-transform: rotate(180deg); transform: rotate(180deg) } </style> <script type="text/babel"> export default { data() { return { list: [], allLoaded: false, bottomStatus: '', wrapperHeight: 0, topStatus: '', //wrapperHeight: 0, translate: 0, moveTranslate: 0 }; }, methods: { handleBottomChange(status) { this.bottomStatus = status; }, loadBottom() { setTimeout(() => { let lastValue = this.list[this.list.length - 1]; if (lastValue < 40) { for (let i = 1; i <= 10; i++) { this.list.push(lastValue + i); } } else { this.allLoaded = true; } this.$refs.loadmore.onBottomLoaded(); }, 1500); }, handleTopChange(status) { this.moveTranslate = 1; this.topStatus = status; }, translateChange(translate) { const translateNum = +translate; this.translate = translateNum.toFixed(2); this.moveTranslate = (1 + translateNum / 70).toFixed(2); }, loadTop() { setTimeout(() => { let firstValue = this.list[0]; for (let i = 1; i <= 10; i++) { this.list.unshift(firstValue - i); } this.$refs.loadmore.onTopLoaded(); }, 1500); }, }, created() { for (let i = 1; i <= 20; i++) { this.list.push(i); } }, mounted() { this.wrapperHeight = document.documentElement.clientHeight - this.$refs.wrapper.getBoundingClientRect().top; } }; </script>
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
ajax+springmvc实现C与View之间的数据交流方法
以上就是vue2 mint-ui loadmore实现下拉刷新,上拉更多功能的详细内容,更多请关注其它相关文章!
上一篇: PHP之消息队列
下一篇: Java陷阱之assert关键字详解
推荐阅读
-
H5基于iScroll实现下拉刷新和上拉加载更多
-
IScroll5实现下拉刷新上拉加载的功能实例
-
微信小程序实现页面下拉刷新和上拉加载功能详解
-
vue实现网络图片瀑布流 + 下拉刷新 + 上拉加载更多
-
解决Vue使用mint-ui loadmore实现上拉加载与下拉刷新出现一个页面使用多个上拉加载后冲突问题
-
Android通过XListView实现上拉加载下拉刷新功能
-
VUE2配合mint-ui实现自定义loadmore(下拉刷新,上拉更多)教程
-
vue2 mint-ui loadmore实现下拉刷新,上拉更多功能
-
angularjs实现上拉加载和下拉刷新数据功能
-
SwipeRefreshLayout+RecyclerView实现上拉刷新和下拉刷新功能