<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. SVN合并时报错:合并跟踪不允许丢失子树Merge tracking not allowed with missing subtrees; try restoring these items

    使用的是TortoiseSVN; Merge tracking not allowed with missing subtrees; try restoring these items 下面会有跟着几 ...

  2. Linxu下 expect的安装与使用

    expect学习 1.什么是except        Expect是基于Tcl的一个相对简单的免费脚本文件语言工具,用于实现自动和交互式程序进行通信            is a software ...

  3. Hive开窗函数的理解

    1.从一个sql语句开始 select id,sum(price) over(partition by id order by price desc) from books; sum作为聚合函数的时候 ...

  4. rsync- sersync -inotify

    Rsync简介 Rsync是一款优秀的.快速的.多功能的本地或远程数据镜像同步备份工具.适用于unix/linux/windows等多种平台 从软件的名称Rsync(Remote Rynhroniza ...

  5. docker 17.09.0-ce 启动更换网络地址

    一.环境准备 环境1 台虚拟机,系统为centos7 二.17.09.0-ce 安装 卸载安装的所有Docker组件 在 Docker17.03.0-ce 版本中,与在 Docker 1.12 中引入 ...

  6. December 23rd 2016 Week 52nd Friday

    Life is a horse, and either you ride it or it rides you. 人生像一匹马,你不驾驭它,它便驾驭你. It is the same meaning ...

  7. 一个简单的php分页逻辑

    php分页 <?php include 'backend/conn.php'; $html = '<ul>'; //输出的html $pageDataNum=3; //每页显示10行 ...

  8. 【解决方案】[XCUITest] WDA is not listening at 'http://localhost:8100/'

    1. 使用Xcode 编译 WebDriver 发现端口为:serverurlhere->http://手机ip:0 <-serverurlhere 2. 解决方案: xcodebuild ...

  9. Debian 静态网络配置

    allow-hotplug enp6s0 iface enp6s0 inet static address gateway 192.168.2.1 # dns-* options are implem ...

  10. 死磕salt系列-salt 故障汇总

    这里将salt使用过程中遇到的所有的故障进行一个汇总. grains 匹配后多了一个列表 salt-master中配置jinja模板来匹配自定义的grins. vim /etc/salt/minion ...