Vue2.x中使用DataV中的轮播表

QQ录屏20230519174802

一、使用过程中遇到的问题

        1. 对分页接口进行分部加载(一次调10条知道调完所有数据)

        2. 将接口返回的一段一段的数据处理成DataV中轮播表所需要的格式

        3. 轮播表数据不更新

二、解决问题

        思路:maxResultCount 单次查询的最大条数(随意 int类型)

                   skipCount 跳过多少条数据查询 

                    判断接口返回的数据res的数组长度来判断是否继续查询,数组长度为0就对数据进行                      处理,处理完数据后使用拓展运算符更新数据

                    具体实现看下面代码

getTenantResourcesList() {
      let pages = this.page
      this.skipCount = (pages - 1) * this.size
      this.maxResultCount = this.size

      this.$axios.gets(`/api/base/common/getTenantResourcesList?maxResultCount=${this.maxResultCount}&skipCount=${this.skipCount}`).then((res) => {
        if (res.items.length === 0) {
          let data = []
          this.resDataArray.forEach((item) => {
            data.push([item.tenantName, item.surplusQuantity, item.surplusSize, item.totalQuantity, item.totalSize, item.usedQuantity, item.usedSize]) //公司名称
          })

          this.config.data = data
          this.config = { ...this.config }
          this.resDataArray = []
          this.page = 1
        }

        if (res.items.length !== 0) {
          this.getTenantResourcesList()
          res.items.forEach((element) => {
            this.resDataArray.push(element)
          })
        }

        this.page += 1
      })
    },

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值