vue3--element组件分页功能

简介: vue3--element组件分页功能

直接上代码:

我用的是element组件

首先是列表data是数据源

<el-table :data="data.slice((currentPage - 1) * limit, currentPage * limit)" stripe  border style="width: 100%">
      <el-table-column prop="id" header-align="center" align="center" show-overflow-tooltip label="标识" width="70" />
      <el-table-column prop="title" header-align="center" align="center" show-overflow-tooltip label="项目名称" width="220" />
      <el-table-column prop="companyid" header-align="center" align="center" show-overflow-tooltip label="公司标识" width="220" />
      <el-table-column prop="account" header-align="center" align="center" show-overflow-tooltip label="公司名称" width="220" />
      <el-table-column prop="address" header-align="center" align="center" show-overflow-tooltip label="项目地址"  width="220" />
      <el-table-column prop="end_time" header-align="center" align="center" show-overflow-tooltip label="结束时间"  width="220" />
      <el-table-column prop="start_time" header-align="center" align="center" show-overflow-tooltip label="开始地址"  width="220" />
      <el-table-column label="操作" header-align="center" align="center" show-overflow-tooltip>
      <template #default="{row}">
        <el-button text @click="dialogFormVisible_edit = true">
            <el-button size="small" @click="handleEdit(row.id)">编辑</el-button>
        </el-button>
        <el-button text @click="open(row.id)">
            <el-button
          size="small"
          type="danger"
        >下架</el-button>
        </el-button>
      </template>
    </el-table-column>
    </el-table>
<div class="demo-pagination-block">
    <el-pagination
    v-model:page-size="limit"
     v-model:current-page="currentPage"
      :page-sizes="[5, 10, 15, 20, 25]"
      :small="small"
      :disabled="disabled"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      :total="data.length"//data的长度
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>

vue代码:

/**分页 */
const small = ref(false)
const background = ref(false)
const disabled = ref(false)
const currentPage = ref(1);
  const limit = ref(10);
const handleSizeChange = (val: number) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val: number) => {
  console.log(`current page: ${val}`)
}


相关文章
|
17天前
|
资源调度 JavaScript API
vue3封装城市联动组件
vue3封装城市联动组件
|
20天前
|
JavaScript 前端开发 开发者
哇塞!Vue.js 与 Web Components 携手,掀起前端组件复用风暴,震撼你的开发世界!
【8月更文挑战第30天】这段内容介绍了Vue.js和Web Components在前端开发中的优势及二者结合的可能性。Vue.js提供高效简洁的组件化开发,单个组件包含模板、脚本和样式,方便构建复杂用户界面。Web Components作为新兴技术标准,利用自定义元素、Shadow DOM等技术创建封装性强的自定义HTML元素,实现跨框架复用。结合二者,不仅增强了Web Components的逻辑和交互功能,还实现了Vue.js组件在不同框架中的复用,提高了开发效率和可维护性。未来前端开发中,这种结合将大有可为。
61 0
|
21天前
|
JavaScript 开发者
[译] 监听第三方 Vue 组件的生命周期钩子
[译] 监听第三方 Vue 组件的生命周期钩子
|
21天前
|
JavaScript 前端开发
[译] 复用 Vue 组件的 6 层手段
[译] 复用 Vue 组件的 6 层手段
|
21天前
|
JavaScript API
vue 批量自动引入并注册组件或路由
vue 批量自动引入并注册组件或路由
|
29天前
|
JavaScript 程序员 开发者
vue组件的使用与基础知识你真的完全明白吗?
【8月更文挑战第16天】vue组件的使用与基础知识你真的完全明白吗?
33 3
vue组件的使用与基础知识你真的完全明白吗?
|
17天前
|
存储 JavaScript
vue组件的五种传值方法(父子\兄弟\跨组件)
vue组件的五种传值方法(父子\兄弟\跨组件)
|
21天前
|
JavaScript 前端开发 Serverless
[译] VueJS 中更好的组件组合方式
[译] VueJS 中更好的组件组合方式
|
21天前
|
JavaScript
Vue3相关组件项目依赖依赖版本信息
这篇文章展示了一个Vue 3项目中使用的组件和库的依赖版本信息,包括`ant-design-vue`、`swiper`、`vue`、`vue-router`等,以及开发依赖如`vite`、`vue-tsc`、`eslint`等。
Vue3相关组件项目依赖依赖版本信息
|
21天前
|
JavaScript 前端开发 测试技术
[译]: Vue.js 函数式组件:what, why & when?
[译]: Vue.js 函数式组件:what, why & when?
[译]: Vue.js 函数式组件:what, why & when?