微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

v-data-table 在渲染/创建之前加载数据 - SSR

如何解决v-data-table 在渲染/创建之前加载数据 - SSR

我使用 vuetify v-data-table 和服务器端和分页 + SSR 进行了 crud 操作。问题是页面加载后正在获取数据。有没有什么方法可以在页面加载之前加载数据,与 asyncData 或 fetch hook 等 SSR 相关?

组件:

<v-data-table
      :headers="headers"
      :items="list"
      item-key="_id"
      :options.sync="options"
      :server-items-length="countItems"
      :items-per-page="10"
      :footer-props="{
          itemsPerPageOptions:[10,50,100,-1],'show-current-page': true,'show-first-last-page': true
      }"
      dense
    />

观看:

watch:{    
    params: {
      handler() {
        this.filteredCustomers();
      },deep: true
    }
  }
methods: {
    async filteredCustomers(){
      try {
        const { data } = await this.$axios.post(`${process.env.CUSTOMER_SERVICE}/fetch-filtered-customers`,this.params );
        this.countItems = data.count[0]?.__v || 0
        this.list = data.customers;
      } catch (error) {
        this.$notifier.showMessage( { message : error.response?.data || error } );
      }
    },}

computed: {

    params(nv) {
      return {
        ...this.options,search: this.search,type: this.filter
      }
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。