demo地址:https://github.com/zphtown/cube-ui-bug

上拉和下拉核心代码:

  onPullingDown () {
this.isNoMore = false
this.from = 1
this.getList(1)
},
onPullingUp () {
if (this.isNoMore) {
this.$refs.indexList.forceUpdate()
return
}
this.getList()
},
getList (isUpdate) {
axios.get('http://api.zphtown.com/getGoldList.php', {
params: {
from: this.from,
size: this.size
}
})
.then(res => {
const { list } = res.data
const len = list.length
let arr = []
list.map(v => {
let time = parseTime(v.createTime, '{y}年{m}月')
let index = arr.findIndex(v2 => v2.name === time)
if (index === -1) {
arr.push({
name: time,
items: []
})
}
arr[index > -1 ? index : arr.length - 1].items.push(v)
})
if (isUpdate) {
if (len) {
this.list = arr
} else {
this.$refs.indexList.forceUpdate()
}
} else {
arr.map(v => {
let index = this.list.findIndex(v2 => v2.name === v.name)
if (index > -1) {
this.list[index].items.push(...(v.items))
} else {
this.list.push(v)
}
})
if (len) {
if (len === this.size) {
setTimeout(() => {
this.$refs.indexList.forceUpdate(true)
}, 30)
} else {
console.log('nodata')
this.isNoMore = true
setTimeout(() => {
this.$refs.indexList.forceUpdate(true, true)
}, 30)
}
} else {
this.$refs.indexList.forceUpdate()
this.isNoMore = true
}
this.from++
}
})
}
}

划重点:

最新文章

  1. javascript的假查询
  2. JavaScript初学者应注意的七个细节(转)
  3. watchdog机制
  4. Red5边源服务器集群部署
  5. u-boot中分区和内核MTD分区关系
  6. [Typescript] Function defination
  7. MVC4过滤器(转)
  8. 积累的VC编程小技巧之文件操作
  9. ThinkPhp学习13
  10. MATLAB符号极限、导数及级数求和
  11. Vue 表单验证插件
  12. pouchdb-all-dbs插件
  13. 简单的GIT上传
  14. 在MVC中Dashboard基础入门操作
  15. 雅礼 noip2018 模拟赛 day3 T3
  16. java用poi读取Excel表格中的数据
  17. jzoj3084
  18. Python标准库 之 turtle(海龟绘图)
  19. poj 2155 (二维树状数组 区间修改 求某点值)
  20. ubuntu下访问支付宝官网,安装安全控件

热门文章

  1. react 的基础知识
  2. vue-cli 3x 的使用
  3. java单例模式实现
  4. linux常用关机和重启命令
  5. CSS中盒子模型
  6. 数据中心网络架构的问题与演进 — Overlay 网络
  7. FAQ_2
  8. iOS去除数组中重复的model数据
  9. axios在Vue中的简单应用(一)
  10. Day05:集合操作——线性表(二) / 查找表 / 文件操作——File(一)