通过this.$set()方法更新了页码table数据条数后,页面底部的翻页total不随着更新

发布于 2023-02-26 16:04:36

一、问题描述:
1、在index.vue页面里面,通过this.$set()方法更新了table的数据条数;
2、这个数据条数是通过参数过滤的,不是通过顶部的搜索框;
3、列表数据虽然更新了,但翻页没有更新,也就是total还是显示的原来api过来的数据长度,不是新更新的数据长度。
比如:原来API数据长度total=30,页面过滤后数据为20,但底部翻页组件显示的还是30条数据。
请求:这个是什么原因?怎么解决这个问题?
二、代码:

async pageRequest(query) {
      // 1、获取远程数据
      const ret = await GetList(query)
      this.DataList = ret.data.data
      this.$nextTick().then(async () => {
        await this.$nextTick()
        // 2、获取A页面传递的linkYear参数
        this.SDate = this.$route.params.linKYear + '-01-01'
        this.EDate = this.$route.params.linKYear + '-12-31'
            // 3、根据参数过滤列表数据
        if (this.$route.params.linKYear != null) {
          this.newtableData.length = 0

          this.DataList.forEach(item => {
            if (item.sign_date >= this.SDate && item.sign_date <= this.EDate) {
              if (this.$route.params.DataType == 'XQ') {
                this.newtableData.push(item)
              }
              else if (this.$route.params.DataType == 'QF') {
                if (item.contract_type == 2) {
                  this.newtableData.push(item)
                }
              }
            }
          });
          // 4、将过滤的数据更新到tableData
          // ret.data.total == this.newtableData.length
          this.$set(this.getD2Crud(), 'd2CrudData', this.newtableData)
        } else {
          console.log('4-没获取到LinkYear', this.$route.params.linKYear);
        }
      })
      return ret
    },

查看更多

关注者
0
被浏览
385
1 个回答
hongzai
hongzai 认证专家 2023-02-27
life is coding,外包,远程协助,咨询添加微信:H0nGzA1

crud有个方法是refresh表格,需要手动调用一下

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览