Skip to content
Title

Pagination 分页

你总不能一口气展示完所有数据吧

使用

vue
<template #source>
  <div>
    <div>
      <a v-for="article of articles">
        <div>
          <div>
            <span>{{ article.title }}</span>
          </div>
          <div>
            <span>{{ article.content }}</span>
          </div>
        </div>
      </a>
    </div>
    <b-pagination
      v-model="pageIndex"
      :total="sourceArticles.length"
      :page-size="pageSize"
    ></b-pagination>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
const pageIndex = ref(1)
const pageSize = ref(1)
const articles = computed(() =>
  sourceArticles.value.slice(
    (pageIndex.value - 1) * pageSize.value,
    pageIndex.value * pageSize.value
  )
)
const sourceArticles = ref([
  {
    title: '我是标题1',
    content: '我是内容1'
  },
  {
    title: '我是标题2',
    content: '我是内容2'
  },
  {
    title: '我是标题3',
    content: '我是内容3'
  },
  {
    title: '我是标题4',
    content: '我是内容4'
  }
])
</script>
展开代码

API

Pagination Props

属性值说明类型默认值
total总条目数number
page-size每页显示条目个数number10
pager-count设置最大页码按钮数。 页码按钮的数量,当总页数超过该值时会折叠number7

Released under the MIT License.