fix: setTimeout 改调 Taro.nextTick 调用,保证rect能够获取成功#3369
fix: setTimeout 改调 Taro.nextTick 调用,保证rect能够获取成功#3369xiaoyatong merged 1 commit intojdf2e:feat_v3.x_cppfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a timing issue in the NoticeBar component by replacing setTimeout with Taro.nextTick to ensure DOM element dimensions can be retrieved successfully.
Key Changes
- Replaced
setTimeout(..., 0)withTaro.nextTick()in the scroll calculation logic - Added Taro import to support the new API call
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Walkthrough在 Taro 版 NoticeBar 组件中,引入了 @tarojs/taro,并将 initScrollWrap 内部的 setTimeout(..., 0) 调度改为 Taro.nextTick(...),使布局计算在下一次事件循环执行。未改动导出或公开接口。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant NB as NoticeBar (Taro)
participant T as Taro.nextTick
participant L as Layout/DOM
U->>NB: 初始化/挂载
NB->>T: 调度 initScrollWrap
Note right of T: 等待下一轮事件循环
T-->>NB: 回调执行
NB->>L: 读取尺寸/计算滚动参数
NB-->>U: 完成滚动初始化
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit