ZBLOG

你的代码大体上是正确的,但如果你想修改分页组件中的”Go To”文本为”跳至”,你可以通过自定义 itemRender 属性来实现。在 Ant Design Vue 的表格中,可以使用 pagination 对象来传递此属性。

下面是修改后的代码,添加了自定义 itemRender 来更改 “Go To” 文本:

<template>
  <div class="HistoricalReminder">
    <a-table
      :columns="columns"
      :data-source="data"
      :scroll="{ x: 'max-content' }"
      :pagination="{
        pageSize: pageSize,
        showSizeChanger: true,
        pageSizeOptions: ['5', '10', '20'],
        onShowSizeChange: handlePageSizeChange,
        showQuickJumper: true,
        itemRender: (page, type, originalElement) => {
          if (type === 'jump-prev') {
            return <a>上一页</a>;
          }
          if (type === 'jump-next') {
            return <a>下一页</a>;
          }
          if (type === 'prev') {
            return <a>上一页</a>;
          }
          if (type === 'next') {
            return <a>下一页</a>;
          }
          if (type === 'jump-nearest') {
            return <span>跳至</span>; // 修改这里
          }
          return originalElement; // 其他元素保持不变
        },
        showTotal: (total, range) => `显示 ${range[0]}~${range[1]}条记录,共 ${total} 条记录`
      }"
      :rowClassName="(record, index) => (index % 2 === 0 ? 'red-row' : '')"
    ></a-table>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { CollectionRecord } from '../../utils'; // 确保路径正确

const columns = [
  {
    title: '借据号',
    dataIndex: 'loanInfoCode',
    key: 'loanInfoCode',
    width: 100,
  },
  {
    title: '合同编号',
    dataIndex: 'contractCode',
    key: 'contractCode',
    width: 150,
  },
  {
    title: '客户姓名',
    dataIndex: 'customerName',
    key: 'customerName',
    width: 150,
  },
];

const data = ref([]);
const pageSize = ref(5);

const handlePageSizeChange = (current, size) => {
  console.log(`每页条数变化为: ${size}`);
  pageSize.value = size;
}

const params = {
  draw: 1,
  length: pageSize.value, // 使用当前页面大小
  order: [],
  searchParams: {
    custId: 'A10101',
    dateStart: '',
    dateEnd: ''
  },
};

CollectionRecord(params)
.then((response) => {
   data.value = response.data;
})
.catch((error) => console.error('请求失败:', error));
</script>

修改说明:

  1. itemRender:在分页对象中添加了 itemRender 属性,用于自定义渲染分页项。这允许你将某些文本(例如“Go To”)替换为“跳至”。
  2. 调整参数:确保在调用 CollectionRecord(params) 时,使用的是当前设置的 pageSize.value

这样一来,你就能成功地把分页中的 “Go To” 修改为 “跳至”。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=19327

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?