<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. Grunt入门学习之(1) -- 环境安装

    Grunt入门学习(1) - 环境安装 这周根据项目需要,在项目的基础上分模块开发了一个小的项目板块,但是在规范组织每个模块的代码和其依赖性时比较麻烦,需要一个项目板块的构建工具.各个模块都包括其对应 ...

  2. 4类Storage方案(AS开发实战第四章学习笔记)

    4.1 共享参数SharedPreferences SharedPreferences按照key-value对的方式把数据保存在配置文件中,该配置文件符合XML规范,文件路径是/data/data/应 ...

  3. Angular之 Scope和 Directive

    ---------------------------Scope-------------------------------- https://docs.angularjs.org/guide/sc ...

  4. MySQL允许root远程访问

    1. mysql -u root -p;     // 登录mysql, 并输入密码 2. use mysql;             // 打开 mysql 数据库 3. update user ...

  5. springboot整合fastdfs实现上传和下载

    FastDFS_Client源码 https://github.com/tobato/FastDFS_Client 友情提示:由于FastDFS_Client这个源码不是很多,并且目前没有找到相关文档 ...

  6. Google 嘘! 嘘!

    https://www.gufen.gq(无广告,原guso.ml,ggso.ga,guge.ga) https://c.aiguso.tk (无广告,体验良好) https://d.freedo.g ...

  7. CentOS 7 yum 安装 Nginx

    1.添加Nginx到YUM源 添加CentOS 7 Nginx yum资源库,打开终端,使用以下命令: sudo rpm -Uvh http://nginx.org/packages/centos/7 ...

  8. CentOS 6 系统启动流程

    第一阶段: BIOS启动引导 主板加电,系统自动载入BIOS(Basic Input Output System)系统 BIOS载入CMOS,读取CMOS中设定的硬件工作参数 BIOS进行POST自检 ...

  9. January 04 2017 Week 1st Wednesday

    Nothing happens unless first a dream. 一切始于梦想. I have a dream, one day I can be the expert in this fi ...

  10. C#互操作

    一.引言 “为什么我们需要掌握互操作技术的呢?” 对于这个问题的解释就是——掌握了.NET平台下的互操作性技术可以帮助我们在.NET中调用非托管的dll和COM组件. ..NET 平台下提供了3种互操 ...