计算分页

 

int pgeSize = 200;
Double page = reconciliationDetailsPOList.size() / Double.valueOf(pgeSize);
page = Math.ceil(page);
for (int i = 0; i < page; i++) {
    int start = i * pgeSize;
    int end = (i + 1) == page ? xxx.size() : (i + 1) * pgeSize;
    List<object> temp = xxx.subList(start, end);
    xxxMapper.insertList(temp);
}

 

转载于:https://my.oschina.net/uwith/blog/3049550

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好,这里提供更新后的示例代码,实现上述功能: ``` vue <template> <div> <el-card v-for="(item, index) in currentCards" :key="index" class="card" :body-style="{ padding: '0px' }"> <img :src="item.image" class="image"> <div style="padding: 14px;"> <span class="title">{{ item.title }}</span> <div class="description">{{ item.description }}</div> <div class="operation"> <el-button type="primary">{{ item.buttonText }}</el-button> </div> </div> </el-card> <el-pagination :total="total" :page-size="pageSize" layout="total, prev, pager, next" class="pagination" @current-change="handleCurrentChange"></el-pagination> </div> </template> <script> export default { data() { return { cards: [ { image: 'https://picsum.photos/200/200', title: 'Card 1', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 2', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 3', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 4', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 5', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 6', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 7', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 8', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 9', description: 'This is a card', buttonText: 'Click me' }, { image: 'https://picsum.photos/200/200', title: 'Card 10', description: 'This is a card', buttonText: 'Click me' }, ], currentCards: [], total: 10, pageSize: 5, }; }, mounted() { this.getCurrentCards(); }, methods: { getCurrentCards() { const startIndex = (this.currentPage - 1) * this.pageSize; const endIndex = startIndex + this.pageSize; this.currentCards = this.cards.slice(startIndex, endIndex); }, handleCurrentChange(currentPage) { this.currentPage = currentPage; this.getCurrentCards(); }, }, computed: { currentPage: { get() { return 1; }, set(value) { this.$emit('update:currentPage', value); }, }, totalPages() { return Math.ceil(this.total / this.pageSize); }, }, }; </script> <style scoped> .card { width: calc(20% - 16px); margin-right: 16px; margin-bottom: 16px; } .image { width: 100%; height: 200px; object-fit: cover; } .title { font-size: 18px; font-weight: bold; margin-right: 20px; } .description { margin-top: 12px; margin-bottom: 12px; } .operation { text-align: right; } .pagination { margin-top: 16px; text-align: right; } </style> ``` 这段代码实现了: 1. 使用 `el-card` 生成带图片、内容、操作按钮的卡片。 2. 循环的时候,一行固定五个,最多只有两行共10条数据。 3. 设置好相隔宽度,自动适应屏幕,使用 `calc()` 函数实现自适应宽度。 4. 在底部生成 `elementUI` 的分页,包括总条数和跳转指定页,自动计算分页数量。 5. 使用 `vue2` 脚手架。 需要注意的是,示例代码中的图片使用了 `https://picsum.photos/` 这个网站提供的随机图片。你需要将 `image` 属性替换成自己的图片链接。同时,代码中使用了 `currentPage` 和 `totalPages` 两个计算属性,用于计算当前页和总页数。这两个属性可以在父组件中通过 `v-model` 进行双向绑定,实现分页跳转。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值