Js实现纯数组页码器,使用element pagination样式 vue3+ts

 Js实现纯数组页码器,使用element pagination样式 vue3+ts_第1张图片

 

 
 
        

 

   

const currentPage = ref(1); // 当前页码
const pageSize = ref(20); // 每页数据条数
const total = ref(0); // 数据总数




const getTableList = async () => {
  const res = await TM.API.GetAPIMethodInfoList()
  tableAllData.value = res
  tableData.value = tableAllData.value.slice((currentPage.value - 1) * pageSize.value, currentPage.value * pageSize.value);
  total.value = res.length;
}

const onHandleSizeChange = (newSize: number) => {
  pageSize.value = newSize;
  // currentPage.value = 1; // 切换每页数据条数时,回到第一页
  tableData.value = tableAllData.value.slice((currentPage.value - 1) * pageSize.value, currentPage.value * pageSize.value);
};

const onHandleCurrentChange = (newPage: number) => {
  currentPage.value = newPage;
  tableData.value = tableAllData.value.slice((currentPage.value - 1) * pageSize.value, currentPage.value * pageSize.value);
};

你可能感兴趣的:(javascript,vue.js,elementui)