<template>
<div class="page page-scroller">
<scroller
class="scroller"
style="padding-top: 0"
:on-refresh="refresh"
:on-infinite="infinite"
ref="my_scroller"
>
<div v-for="(item, index) in items" class="row" :class="{'grey-bg': index % 2 == 0}" :key="index">
{{ item.name }}{{index}}
</div>
</scroller>
</div>
</template> <script>
import Vue from 'vue'
import VueScroller from 'vue-scroller'
Vue.use(VueScroller)
export default {
name: 'PageScroller',
data () {
return {
pageSize: 5, // 分页大小
currentPageNo: 0, // 当前页码
items: [],
    isEmpty: true,
noData: false
}
},
mounted () {},
methods: {
    // 查询方法
    searching () {
     this.pageNo = 1
     this.$refs.my_scroller.finishInfinite(false) // 启用上拉加载更多
     this.noData = true
     this.isEmpty = false
     this.$refs.my_scroller.scrollTo(0, 0, false) // 列表滚动到顶部
     this.findList()
    },
// 查询列表数据
findList (done) {
let url = '/app/approveList'
this.ABILITY.request.mock(url).then(res => {
console.log(res)
let data = res.data
if (this.currentPageNo === 1) {
this.items = data
done && done()
this.$refs.my_scroller.finishPullToRefresh()
this.$refs.my_scroller.finishInfinite(false) // 启用上拉加载更多
this.noData = false
} else {
this.items = this.items.concat(data)
done && done()
if (data.length === 0) {
this.noData = true
} else {
this.$refs.my_scroller.finishInfinite(false)
}
}
})
}, // 下拉刷新
refresh (done) {
let self = this
self.currentPageNo = 1
setTimeout(() => {
self.findList(done)
}, 1500)
}, // 初始化
infinite (done) {
let self = this
if (self.noData) {
self.$refs.my_scroller.finishInfinite(true) // 禁止上拉加载更多
return false
}
self.currentPageNo++
setTimeout(() => {
self.findList(done)
}, 1500)
}
}
}
</script> <style lang="less">
@import url("./Scroller.less");
</style>

scroller组件的容器,使用绝对定位设置好高度

vue-scroller使用的更多相关文章

  1. Vue Scroller:Vue 下拉刷新及无限加载组件

    Vue Scroller Vue Scroller is a foundational component ofVonic UI. In purpose of smooth scrolling, pu ...

  2. Vue 下拉刷新及无限加载组件

    原文  https://github.com/wangdahoo/vue-scroller 主题 Vue.js Vue Scroller Vue Scroller is a foundational ...

  3. vuejs实现瀑布流布局(三)

    前面写过vuejs实现的瀑布流布局,<vuejs实现瀑布流布局(一)>和<vuejs实现瀑布流布局(二)>也确实实现了瀑布流布局,但是这个是基于SUI-Mobile实现的无限滚 ...

  4. vue 的 scroller 使用

    一 安装 使用npm 安装npm install vue-scroller -d 二 引入 import VueScroller from "vue-scroller" Vue.u ...

  5. 如何优雅的使用vue+vux开发app -03

    如何优雅的使用vue+vux开发app -03 还是一个错误的示范,但是离优雅差的不远了... <!DOCTYPE html> <html> <head> < ...

  6. 如何优雅的使用vue+vux开发app -02

    如何优雅的使用vue+vux开发app -02 很明显这又是一个错误的示范,请勿模仿 使用动态组件实现保留状态的路由 <!DOCTYPE html> <html> <he ...

  7. 如何优雅的使用vue+vux开发app -01

    如何优雅的使用vue+vux开发app -01 很明显下面是个错误的示范: <!DOCTYPE html> <html> <head> <title>v ...

  8. vue.js移动端app实战2:首页

    貌似有部分人要求写的更详细,这里多写一点vuel-cli基础的配置 什么是vue-cli? 官方的解释是:A simple CLI for scaffolding Vue.js projects, 简 ...

  9. vue.js移动端app实战4:上拉加载以及下拉刷新

    上拉加载以及下拉刷新都是移动端很常见的功能,在搜索或者一些分类列表页面常常会用到. 跟横向滚动一样,我们还是采用better-scroll这个库来实现.由于better已经更新了新的版本,之前是0.几 ...

  10. 快速构建一个简单的单页vue应用

    技术栈 vue-cli webpack vux,vux-loader less,less-loader vue-jsonp vue-scroller ES6 vue-cli:一个vue脚手架工具,利用 ...

随机推荐

  1. 服务器端的tomcat,servlet框架

    tomcat是一个服务器程序 可以对webapp目录下的Servlet代码进行执行和操作 编写的Servlet代码的步骤一般是在本地的ide中编写和测试,然后打包工程为war格式的文件,部署在服务器t ...

  2. No enum constant org.apache.ibatis.type.JdbcType.Integer

    同事今天在用mybatis查询时候,报了上面这个问题.上网查了下,原来是mybatis封装类型的问题.原因是在resultMap中jdbcType写为了Integer,但是在MyBatis中没有这个数 ...

  3. Windows下部署ElasticSearch5.0以下版本

    Windows下部署ElasticSearch分ElasticSearch5.0以上版本(包括5.0)和ElasticSearch5.0以下版本两种情况,这两种安装方式有很大不同.今天首先说Elast ...

  4. Java Web开发中的转发和重定向的问题

    Java Web的页面实现跳转有两种方式,一种是转发,另外一种是重定向.一般来说,转发比重定向快.重定向会经过客户端,转发却不会. 转发 request.getRequestDispatcher(&q ...

  5. 二、python小功能记录——监听鼠标事件

    1.原文链接 #-*- coding:utf-8 -*- from pynput.mouse import Button, Controller ## ======================== ...

  6. Python学习---django多对多之Djanog默认表学习

    案例一: from django.db import models class Book(models.Model): name = models.CharField(max_length=33) # ...

  7. 企业级Apache详解

    安装Apache #Apache安装 rpm -qa|grep httpd yum install httpd #2编译安装: -->推荐安装 cd /root/software yum -y ...

  8. 多变量线性回归 matlab

    %multivariate_linear_regression data=load('data.txt'); x=data(:,1:2); y=data(:,3); m=length(x(:,1)); ...

  9. Azure 负载内部均衡器概述

    Azure 内部负载均衡器 (ILB) 仅将流量定向到云服务内的资源,或使用 VPN 来访问 Azure 基础结构. 在这一点上,ILB 与面向 Internet 的负载均衡器不同. Azure 基础 ...

  10. July 27th 2017 Week 30th Thursday

    A smile is the most charming part of a person forever. 微笑永远是一个人身上最好看的东西. Smile in the mirror, and yo ...