<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. 最好的原型和流程图绘制工具:OmniGraffle_交互设计

    原文地址:http://www.shangxueba.com/jingyan/2230668.html 使用哪种原型设计工具"大概是设计师闲聊时出现频率最高的话题之一.据我了解一般以Visi ...

  2. centos7上安装python3

    一.安装环境及版本 CentOS 6.5 Python 3.6.1 二.安装依赖包 1.安装静态库 # yum install -y openssl-static 注:如果不安装该静态库,会导致pyt ...

  3. windows程序设置开机自动启动

    //调用方法:设置开机启动 SetAutoRun(Process.GetCurrentProcess().ProcessName, true, Application.StartupPath + @& ...

  4. 沉淀,再出发:sublime中快捷键和html标签的使用和生成以及使用markdown

    沉淀,再出发:sublime中快捷键和html标签的使用和生成以及使用markdown 一.前言 工欲善其事,必先利其器.在软件代码的编写中,一定要知道IDE或者编辑器的快捷键的使用,这样可以提高很多 ...

  5. CopyrightHelper—开源VS插件辅助插入版权注释

    前言 有很多时候,我们在写代码的时候需要在代码文件头加上描述和版权信息等,如果使用代码项目模板又得为每种文件定模板,而已不方便,如果从某个地方复制过来,又嫌麻烦... 为了能解决这种懒人的需求,我开始 ...

  6. 在ubuntu上使用QQ的经历

    pidgin-lwqq: 项目首页:https://github.com/xiehuc/pidgin-lwqq sudo add-apt-repository ppa:lainme/pidgin-lw ...

  7. 在CentOS7上安装和使用ZooKeeper最新版本(V3.4.12)

    0.ZooKeeper文档 http://zookeeper.apache.org/doc/r3.4.11/zookeeperOver.html 1.准备 在CentOS7上安装zookeeper时, ...

  8. python中执行shell命令

    查看输出结果 import os output = os.popen('cat 6018_gap_5_predict/solusion2/solusion2_0-1.txt | wc -l') pri ...

  9. Emacs 快速指南 - 原生中文手册

    Emacs 快速指南 -折叠目录 1. 小结(SUMMARY) 2. 基本的光标控制(BASIC CURSOR CONTROL) 3. 如果 EMACS 失去响应(IF EMACS STOPS RES ...

  10. linux 相关命令

    Linux 不同用户环境变量 修改所有用户的环境变量:/etc/profile文件 只修改root用户的环境变量:~/.bashrc文件 只修改某个非root用户的环境变量:/home/非root用户 ...