• cube-ui indexList的正确使用


    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++
            }
          })
        }
      }

    划重点:

  • 相关阅读:
    Linux文件权限管理
    Linux用户权限管理
    压缩,解压缩 和tar详细介绍
    grep基本详细使用
    Vim文本编辑器详细用法
    Linux命令查找文件目录
    Linux文件增删改
    Linux目录管理
    Linux修改主机名
    Linux创建高级用户并删除
  • 原文地址:https://www.cnblogs.com/zph666/p/11069344.html
Copyright © 2020-2023  润新知