<template>

<div class="page-loadmore">
<h1 class="page-title">Pull up</h1> <div class="page-loadmore-wrapper" ref="wrapper" :style="{height : wrapperHeight + 'px' }">
<mt-loadmore
:bottom-method="loadBottom"
:bottom-all-loaded="allLoaded"
@bottom-status-change="handleBottomChange"
:auto-fill="false"
ref="loadmore"
> <ul class="page-loadmore-list">
<li v-for="item in list" class="page-loadmore-listitem">{{ item }}</li>
</ul> <div 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>
</div> </mt-loadmore>
</div>
</div>
</template> <script>
export default {
data() {
return {
list: [],
totalLength:'', //数据总长度
nowLength:'', //当前list的长度
nextLength:'', //下一次的长度
num:, //每页的数量
allLoaded: false, //是否全部加载
wrapperHeight: , bottomStatus:''
};
}, methods: {
handleBottomChange(status){
this.bottomStatus = status;
},
loadBottom() {
setTimeout(() => {
//console.log('nowLength:',this.nowLength) //10
//console.log('totalLength:',this.totalLength) //
if (this.nowLength <= this.totalLength) {
this.$http.jsonp('http://json.cn/json.php',
{
params:{},
jsonp:'callback'
}).then(function(res){ if(this.nowLength+this.num<this.totalLength){
this.nextLength=this.nowLength+this.num
}else{
this.nextLength=this.totalLength
} for(let i=this.nowLength; i<this.nextLength; i++){
this.list.push(res.data.s[i] + i)
} this.nowLength+=this.num;
},function(res){
console.log(res.status);
}) } else {
this.allLoaded = true;
}
this.$refs.loadmore.onBottomLoaded();
}, );
}
}, created() {
this.$http.jsonp('http://json.cn/json.php',
{
params:{},
jsonp:'callback'
}
).then(function(res){ //如果成功
for(let i=; i<this.num; i++){
this.list.push(res.data.s[i] + i) //将10条数据推入this.list
}
this.nowLength = this.list.length; //nowLength=10
this.totalLength = res.data.s.length; //所有数据的长度29
},function(res){ //如果失败
console.log(res.status);
})
}, mounted() { //wrapperHeight=可见区域高度-wrapper到视窗的顶部
this.wrapperHeight = document.documentElement.clientHeight - this.$refs.wrapper.getBoundingClientRect().top;
}
}
</script> <style lang="less" scoped>
.page-loadmore-wrapper {
overflow: scroll;
} .page-loadmore-listitem {
height: 50px;
line-height: 50px;
text-align: center;
border-bottom: 1px solid #eee;
} .page-loadmore-listitem:first-child {
border-top: 1px solid #eee
} .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>

参考:https://www.cnblogs.com/yuri2016/p/7045709.html

vue2 mint-ui loadmore(下拉刷新)的更多相关文章

  1. vue2 mint-ui loadmore(下拉刷新,上拉更多)

    <template> <div class="page-loadmore"> <h1 class="page-title"> ...

  2. Vue mint ui用在消息页面上拉加载下拉刷新loadmore 标记

    之前总结过一个页面存在多个下拉加载的处理方式,今天再来说一下在消息页面的上拉加载和下拉刷新,基本上每个app都会有消息页面,会遇到这个需求 需求:每次加载十条数据,上拉加载下拉刷新,并且没有点击查看过 ...

  3. vue2.0 移动端,下拉刷新,上拉加载更多插件,修改版

    在[实现丰盛]的插件基础修改[vue2.0 移动端,下拉刷新,上拉加载更多 插件], 1.修改加载到尾页面,返回顶部刷新数据,无法继续加重下一页 2.修改加载完成文字提示 原文链接:http://ww ...

  4. Vue-上拉加载与下拉刷新(mint-ui:loadmore)一个页面使用多个上拉加载后冲突问题

    所遇问题: 该页面为双选项卡联动,四个部分都需要上拉加载和下拉刷新功能,使用的mint-ui的loadmore插件,分别加上上拉加载后,只有最后一个的this.$refs.loadmore.onTop ...

  5. vue---mint-ui组件loadmore(上拉加载,下拉刷新)

    1. 先安装mint-ui 2. 在main.js中引入mint-ui的css样式和组件 import "mint-ui/lib/style.css"; import {Loadm ...

  6. vue2.0 自定义 下拉刷新和上拉加载更多(Scroller) 组件

    1.下拉刷新和上拉加载更多组件 Scroller.vue <!-- 下拉刷新 上拉加载更多 组件 --> <template> <div :style="mar ...

  7. vue2.0 移动端,下拉刷新,上拉加载更多 封装组件

    前言 在做移动端的避免不了 下拉刷新,上拉加载 直接上代码吧,哈哈 组件里: <template lang="html"> <div class="yo ...

  8. vue和mint-ui loadMore 实现上拉加载和下拉刷新

    首先安装mint-ui组件库 npm install mint-ui 在main.js中引入mint-ui和样式 import 'mint-ui/lib/style.css' import MintU ...

  9. Qt qml listview 列表视图控件(下拉刷新、上拉分页、滚动轴)

    Qt qml listview下拉刷新和上拉分页主要根据contentY来判断.但要加上顶部下拉指示器.滚动条,并封装成可简单调用的组件,着实花了我不少精力:) [先看效果]    [功能] 下拉刷新 ...

随机推荐

  1. 在其他Activity中展示自定义相机拍的照片

    在使用相机拍照中,我们需要当点击了确定按钮之后,拍的照片展示在其他Activity的ImageView中,代码如下: 1.首先在自定义相机的Activity中,处理点击拍照确定按钮后的逻辑功能:将图片 ...

  2. Linux笔记-top命令和load average

    参考资料 top相关: http://blog.csdn.net/zhangchenglikecc/article/details/52103737参考资料 cpu核数: https://www.cn ...

  3. face detection[FaceBoxes]

    该文来自<FaceBoxes: A CPU Real-time Face Detector with High Accuracy>.该文时间线是2018年1月 虽然人脸检测上随着深度学习的 ...

  4. .net ElasticSearch-Sql 扩展类【原创】

    官方提供的是java sdk,并支持jdbc方式的查询结果输出;但是却没有.net sdk的支持. 开发 ElasticSearch-Sql 第三方开源项目的.net sdk,未来集成入bsf框架.( ...

  5. 从零开始搭建django前后端分离项目 系列二(项目搭建)

    在开始项目之前,假设你已了解以下知识:webpack配置.vue.js.django.这里不会教你webpack的基本配置.热更新是什么,也不会告诉你如何开始一个django项目,有需求的请百度,相关 ...

  6. C#获取指定IP地址的数据库所有数据库实例名

    /// <summary> /// 获取指定IP地址的数据库所有数据库实例名. /// </summary> /// <param name="ip" ...

  7. C# 对象池的实现(能限制最大实例数量,类似于WCF的MaxInstanceCount功能)

    对象池服务可以减少从头创建每个对象的系统开销.在激活对象时,它从池中提取.在停用对象时,它放回池中,等待下一个请求.我们来看下主线程中,如何与对象池打交道: static void Main(stri ...

  8. abbix通过JMX监控Tomcat(被监控端安装Tomat的服务器防火墙策略iptables配置)

    原文地址:http://jaychang.iteye.com/blog/2214830 一.目前的环境 被监控端192.168.153.191 /usr/local/tomcat 下载了catalin ...

  9. iOS--LaunchImage启动页设置及问题解决

    在Assets.xcassets中使用LaunchImage来设置启动图:   一.根据不同屏幕尺寸的需求设置不同的图片,可以参照下图: 1.点击Image.xcassets 进入图片管理,然后右击, ...

  10. CRM系统(第四部分)

      阅读目录 1.引入权限组件rbac 2.分配权限 3.登录.引入中间件 1.引入权限组件rbac 1.settings配置app.中间件   INSTALLED_APPS = [ ... ... ...