明天的明天 永远的永远 未知的一切 我与你一起承担 ??

是非成败转头空 青山依旧在 几度夕阳红 。。。
随笔 - 1277, 文章 - 0, 评论 - 214, 阅读 - 321万
  博客园  :: 首页  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

官网: https://www.antdv.com/components/list-cn

何时使用 #

最基础的列表展示,可承载文字、列表、图片、段落,常用于后台数据展示页面。

复制代码
<div class="s-table-tool">
            <div class="s-table-tool-left"></div>
            <div class="layout-items-center s-table-tool-right">
            <a-space>
            <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('proProjectFollowAdd')">
                <template #icon><plus-outlined /></template>
                新增
            </a-button>
            </a-space>
        </div></div>
复制代码

 

复制代码
  <a-list size="large" 
    bordered
    :data-source="listData"
    :pagination="pagination"
  >
    <template #renderItem="{ item }">
      <a-list-item>
        <template #actions>
          <a key="list-loadmore-edit" @click="formRef.onOpen(item)" v-if="hasPerm('proProjectFollowEdit')">编辑</a>
          <a-popconfirm title="确定要删除吗?" @confirm="deleteProProjectFollow(item)">
            <a-button type="link" danger size="small" v-if="hasPerm('proProjectFollowDelete')">删除</a-button>
          </a-popconfirm>
        </template>
          <a-list-item-meta
            description="Ant Design, a design language for background applications, is refined by Ant UED Team"
          >
            <template #title>
              <a href="https://www.antdv.com/">{{ item.propName }}</a>
            </template>
            <template #avatar>
              <a-avatar :src="item.fileResult.downloadPath" />
            </template>
          </a-list-item-meta>
          <div>content</div>
      </a-list-item>
    </template>

    <div class="ant-list-pagination">
    <a-pagination v-model:current="pagination.current"
      v-model:page-size="pagination.pageSize"
      :total="pagination.total"
      :showSizeChanger="true"
      :showQuickJumper="true"
      :hideOnSinglePage="false"
      :pageSizeOptions="['1', '10', '20', '40', '80', '100']"
      :show-total="(total, range) => `${range[0]}-${range[1]} 共 ${total} 条`" /> 
    </div>
  </a-list>
复制代码

 

 

脚本:

复制代码
<script setup name="proproject">
    const listData = ref([])
const pagination = ref({
        pageSize: 10,
        current: 1,
        total: 0,
        showTotal:(total, range)=>{
             if(range.length > 0)
              return range[0] + "-" + range[1] + " 共" + total + "条"
             else
             return " 共" + total + "条"
        },
        showSizeChanger: true,//是否显示更改每页条数
        showQuickJumper: true,//是否显示跳至第几页
        pageSizeOptions: ['1', '10', '20', '40', '80', '100'],
        hideOnSinglePage: false, // 只有一页时是否隐藏分页器
        position:'top', //指定分页显示的位置 'top' | 'bottom' | 'both'
        // 设置页面变化时的回调,调用methods中的onChange方法
        onChange: ((e) => {
            pagination.value.current = e
            fetchData(pagination.value.current, pagination.value.pageSize);  
        }),
        // 设置每页显示条数变化时的回调
        onShowSizeChange: (page,pageSize) => {
            pagination.value.current = page
            pagination.value.pageSize = pageSize
            fetchData(pagination.value.current, pagination.value.pageSize);  
        }
    })
 
//调取服务器API
    const fetchData = async (page, pageSize) => {
        try {
            const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
            const result = await proProjectApi.proProjectPage(searchFormParam);
            //console.log(result.records)

            listData.value = result.records;
            pagination.value.total = result.total || 0;
        } catch (error) {
            // 处理错误
        } finally {
            //isLoading.value = false;
        }
    };
 
    onMounted(() => {
       fetchData(pagination.value.current, pagination.value.pageSize);
    });
    
</script>
复制代码

 

相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2022-06-23 Mybatis 请求参数Integer类型值为0源码处理
2010-06-23 .Net 中的webBrowser控件加载网页时实现进度显示
2009-06-23 asp.net 重写URLReWriter实现任意二级域名 [ 转自博客园网友]
2008-06-23 C# WM9播放音乐
2008-06-23 利用批处理文件实现 C#中程序自己删除自己
2006-06-23 使用 Reporting Services 中的窗体身份验证
点击右上角即可分享
微信分享提示