vue2 mint-ui loadmore(下拉刷新)
<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(下拉刷新)的更多相关文章
- vue2 mint-ui loadmore(下拉刷新,上拉更多)
<template> <div class="page-loadmore"> <h1 class="page-title"> ...
- Vue mint ui用在消息页面上拉加载下拉刷新loadmore 标记
之前总结过一个页面存在多个下拉加载的处理方式,今天再来说一下在消息页面的上拉加载和下拉刷新,基本上每个app都会有消息页面,会遇到这个需求 需求:每次加载十条数据,上拉加载下拉刷新,并且没有点击查看过 ...
- vue2.0 移动端,下拉刷新,上拉加载更多插件,修改版
在[实现丰盛]的插件基础修改[vue2.0 移动端,下拉刷新,上拉加载更多 插件], 1.修改加载到尾页面,返回顶部刷新数据,无法继续加重下一页 2.修改加载完成文字提示 原文链接:http://ww ...
- Vue-上拉加载与下拉刷新(mint-ui:loadmore)一个页面使用多个上拉加载后冲突问题
所遇问题: 该页面为双选项卡联动,四个部分都需要上拉加载和下拉刷新功能,使用的mint-ui的loadmore插件,分别加上上拉加载后,只有最后一个的this.$refs.loadmore.onTop ...
- vue---mint-ui组件loadmore(上拉加载,下拉刷新)
1. 先安装mint-ui 2. 在main.js中引入mint-ui的css样式和组件 import "mint-ui/lib/style.css"; import {Loadm ...
- vue2.0 自定义 下拉刷新和上拉加载更多(Scroller) 组件
1.下拉刷新和上拉加载更多组件 Scroller.vue <!-- 下拉刷新 上拉加载更多 组件 --> <template> <div :style="mar ...
- vue2.0 移动端,下拉刷新,上拉加载更多 封装组件
前言 在做移动端的避免不了 下拉刷新,上拉加载 直接上代码吧,哈哈 组件里: <template lang="html"> <div class="yo ...
- vue和mint-ui loadMore 实现上拉加载和下拉刷新
首先安装mint-ui组件库 npm install mint-ui 在main.js中引入mint-ui和样式 import 'mint-ui/lib/style.css' import MintU ...
- Qt qml listview 列表视图控件(下拉刷新、上拉分页、滚动轴)
Qt qml listview下拉刷新和上拉分页主要根据contentY来判断.但要加上顶部下拉指示器.滚动条,并封装成可简单调用的组件,着实花了我不少精力:) [先看效果] [功能] 下拉刷新 ...
随机推荐
- tomcat (选号)公司tomcat无页面解决
问:我现在的有的解决方法就是把上一次war包下下载下来,在重启tomcat 答:那不行,更新war包就没有意义了,你都没排查故障 就直接说war包少东西?主页都没有..还能少主页也不是404.war ...
- node.js之express框架
之前学习过node.js接触过express框架,最近为了编写一个mock server正好用到了express.下面正好就跟大家介绍一下关于express.今天的内容主要围绕这么几个方面? expr ...
- NOIP2018初赛游记
NOIP2018初赛游记 (编辑中)
- [MicroPython]TPYBoardv102自动浇花系统
1.系统功能 监测土壤湿度.环境温度.光照强度 根据当前环境自动浇水,寒冷天气自动加热土壤 2.所需元器件 TPYBoard板子1块 光敏模块1块 DS18B20模块1块 土壤湿度检测模块1块 杜邦线 ...
- jmeter(二十四)dubbo接口测试
最近工作中接到一个需求,需要对一个MQ消息队列进行性能测试,测试其消费能力,开发提供了一个dubbo服务来供我调用发送消息. 这篇博客,介绍下如何利用jmeter来测试dubbo接口,并进行性能测试. ...
- 你知道Java的四种引用类型吗
关于java四种引用类型,我也是刚了解,特此记下! 在Java中提供了四个级别的引用:强引用,软引用,弱引用和虚引用.在这四个引用类型中,只有强引用FinalReference类是包内可见,其他三种引 ...
- 微软Azure AspNetCore微服务实战第1期【补充2017-09-09活动】
2017年09月09日,冒着酷暑,我们在(上海徐汇)虹桥路3号港汇中心2座10层组织了一次微软Azure AspNetCore微服务实战活动. 由于前期工作繁忙,活动完成之后,没能及时发布相关信息,特 ...
- Oracle 一个用户将表权限赋给另一个用户
原文地址:https://blog.csdn.net/u012129031/article/details/76218764 1.将用户user1的表权限赋给用户user2 select 'gra ...
- H5 26-CSS三大特性之优先级
26-CSS三大特性之优先级 类>标签>通配符>继承>浏览器默认 --> 0 我是段落 <!DOCTYPE html> <html lang=" ...
- poj2449 第k短路
题目链接 学习博客:https://blog.csdn.net/Z_Mendez/article/details/47057461 k短路没有我想象的那么难,还是很容易理解的 求s点到t点的第k短路径 ...