Ant Design Vue 官网: 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>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 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 中的窗体身份验证