fix: 🐛 修复分页组件为0时不更新页数问题#903
Conversation
✅ Closes: Moonofweisheng#897
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough此次更改集中在 Changes
Sequence Diagram(s)sequenceDiagram
participant 用户
participant wd分页组件 as wd-pagination.vue
用户->>wd分页组件: 触发分页更新
wd分页组件->>wd分页组件: 执行 updateTotalPage()
wd分页组件->>wd分页组件: 计算 totalPageNum = Math.ceil(total / pageSize)
wd分页组件->>用户: 更新分页显示
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for wot-design-uni ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/uni_modules/wot-design-uni/components/wd-pagination/wd-pagination.vue (2)
102-105: 修复了总数为 0 时的分页问题,建议增加边界条件处理。当前修改解决了总数为 0 时不更新页数的问题,这是正确的方向。不过建议增加一些边界条件的处理,以提高组件的健壮性。
建议按如下方式优化代码:
function updateTotalPage() { const { total, pageSize } = props + if (pageSize <= 0) { + console.warn('[WotDesign] pageSize 必须大于 0') + return + } totalPageNum.value = Math.ceil(total / pageSize) }
76-82: 建议完善 total 属性的类型定义。为了提高代码的类型安全性,建议在 props 的类型定义中明确指定 total 为 number 类型。
建议在
types.ts中更新类型定义:export const paginationProps = { total: { type: Number, required: true } // ... 其他属性 }
✅ Closes: #897
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
#897
💡 需求背景和解决方案
我项目中,商家了一堆活动商品,但由于活动临时变动,需要全部下架,此时用户在滚动的时候,获取到数据total为0了,但是因为if判断跳过了,导致界面的页数不变
☑️ 请求合并前的自查清单
Summary by CodeRabbit