「已注销」 2022-11-16 21:55 采纳率: 0%
浏览 8

vue分页无效,vue3分页无效,vuexy分页

请各位看下,为什么table只加载第一页,点击第二页或第三页table显示为空。明明有数据返回啊

<template>
  <section id="dashboard-analytics">
    


    <b-row>
      <b-col cols="12">
        <ecommerce-statistics :data="data.statisticsItems" />
      </b-col>
    </b-row>


    
    <b-row>
      <b-col cols="12">
        <ecommerce-profit-chart :data="data.statisticsProfit" />
      </b-col>
    </b-row>
    
    <b-row>
      <b-col cols="12">
        

        <b-card title="测试记录">
          <b-table responsive :items="tabledata" class="mb-0" :per-page="perPage" :current-page="currentPage">

          </b-table>
          <b-col cols="12">
            <b-pagination @change="changePage" v-model="currentPage" :total-rows="totalRows" :per-page="perPage"
              align="center" size="sm" class="my-0" />
          </b-col>
        </b-card>



      </b-col>
    </b-row>
  </section>
</template>

<script>
  import {
    BFormGroup, BFormInput, BFormCheckbox, BForm, BButton, BInputGroup, BInputGroupPrepend, BRow, BCol,
    BCard, BCardText, BFormSelect, BTable, BPagination,
  } from 'bootstrap-vue'
  import { ref, watch, computed } from '@vue/composition-api'
  //报表组件
  import EcommerceProfitChart from '@/views/dashboard/ecommerce/EcommerceProfitChart.vue'
  //报表组件
  import EcommerceStatistics from '@/views/kungfu/dashboard/ecommerce/EcommerceStatistics.vue'


  export default {

    components: {

      EcommerceStatistics,
      BRow,
      BCol,
      BFormGroup,
      BFormInput,
      BFormCheckbox,
      BInputGroup,
      BInputGroupPrepend,
      BForm,
      BButton,
      BCard, BCardText, BFormSelect, BTable, BPagination, EcommerceProfitChart


    },
    data() {
      return {

        data: {},
        filter: null,
        filterOn: [],
        pageOptions: [3, 5, 10],
        totalRows: 1,
        //pageNo
        currentPage: 1,
        //pageSize
        perPage: 10,

        attakType: 4,
        dateNtim: null,
        fields: [
          '邮箱',
          'IP',
          '端口',
          '类型',
          '状态',
          '时间',
        ],
        tabledata: [],
        selected4server: 'SERVER01',
        selected4method: 'TCP',
        selected7method: 'HTTP',
        options: [
          { value: 'SERVER01', text: 'SERVER01' },
          { value: 'SERVER02', text: 'SERVER02' },
        ],
        options1: [
          { value: 'TCP', text: 'TCP' },
          { value: 'UDP', text: 'UDP' },
        ],
        attakMethod7: [
          { value: 'HTTP', text: 'HTTP' },
          { value: 'ACK', text: 'ACK' },
          { value: 'SYN', text: 'SYN' },
        ],

      }
    },
    mounted() {
      this.initTableData();
    },


    created() {

      // data
      this.$http.get('/ecommerce/data')
        .then(response => {
          this.data = response.data
          console.log(this.data)
        })

    },
    methods: {
      //kFormatter, 
      onFiltered(filteredItems) {
        // 触发分页以更新由于过滤而产生的按钮/页面数量
        this.totalRows = filteredItems.length
        this.currentPage = 1
      },

      changePage(pager) {
        this.currentPage = pager;
        this.initTableData()
      },
      async initTableData(pager) {
        let request = {}
        console.log("currentPage:" + this.currentPage)
        request.pageNo = this.currentPage;
        request.pageSize = this.perPage;
        await this.$axios.post('/kungfu/attak/list', request).then(response => {
          console.log(response)
          this.tabledata = response.data.data.data;
          this.totalRows = response.data.data.total;
          console.log(this.tabledata)
        })


      }
    },
  }


</script>
<style lang="scss">
  /* 时间组件的css */
  @import "@core/scss/vue/libs/vue-flatpicker.scss";
  /* 报表的css */
  @import '@core/scss/vue/pages/dashboard-ecommerce.scss';
  @import '@core/scss/vue/libs/chart-apex.scss';
</style>
```html









img

```

  • 写回答

2条回答 默认 最新

  • 二九筒 2022-11-17 16:52
    关注

    有可能是你这儿请求的时候用了异步函数,数据还没返回就直接加载了

    评论

报告相同问题?

问题事件

  • 创建了问题 11月16日

悬赏问题

  • ¥15 asp写PC网站开通了微信支付,扫码付款不能跳转
  • ¥50 AI大模型精调(百度千帆、飞浆)
  • ¥15 关于#c语言#的问题:我在vscode和codeblocks中编写c语言时出现打不开源文件该怎么办
  • ¥15 非科班怎么跑代码?如何导数据和调参
  • ¥15 福州市的全人群死因监测点死亡原因报表
  • ¥15 Altair EDEM中生成一个颗粒,并且各个方向没有初始速度
  • ¥15 系统2008r2 装机配置推荐一下
  • ¥500 服务器搭建cisco AnyConnect vpn
  • ¥15 悬赏Python-playwright部署在centos7上
  • ¥15 psoc creator软件有没有人能远程安装啊