【问题标题】:How to disable v-pagination when there are not items VUEJS + VUETIFY没有项目VUEJS + VUETIFY时如何禁用v-pagination
【发布时间】:2021-04-01 07:00:49
【问题描述】:

当列表中没有项目或只有一页时,我想禁用按钮

<v-model="currentPage"
      :length="lastPage"
      total-visible="10"
      prev-icon="mdi-menu-left"
      next-icon="mdi-menu-right"
      @input="handlePageChange"
      class="elevation-0"
      >
</v-pagination>

JS

getCountries() {
            axios
                .get("api/countries/get?page=${this.currentPage}`)
                .then(response => {
                    this.loading = false;
                    this.tableLoading = false;
                    this.countries = response.data.data;
                    this.currentPage = response.data.current_page;
                    this.lastPage = response.data.last_page;                 

                });
        },

【问题讨论】:

  • 您可能会检查总金额以及 lastPage 并使用一些 CSS 隐藏分页。在v-pagination 组件上看起来像这样的:class="[elementsNoneOrOnePageOnly ? 'hidding-class' : '']"

标签: vue.js vuetify.js disable paginator


【解决方案1】:

据我所知,Vuetify 几乎在每个组件上都提供了 disabled 属性。所以我认为你可以在你的 v-pagination 道具中添加:disabled="lastPage &lt;2"

【讨论】:

    猜你喜欢
    • 2020-01-26
    • 2020-01-25
    • 2021-12-18
    • 2020-10-29
    • 2018-03-06
    • 1970-01-01
    • 2021-03-01
    • 2020-04-12
    • 2020-02-01
    相关资源
    最近更新 更多