Skip to content

feat(Tab): support remaining badge component property #13431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

YiMo1
Copy link

@YiMo1 YiMo1 commented Apr 10, 2025

修改Tab组件的Badge属性的类型,在原有的类型上新增剩余的BadgeProps类型(去除已存在的dot和showZero)确保不会对以往的版本有太大的破环性改变。

@codecov-commenter
Copy link

codecov-commenter commented Apr 10, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.71%. Comparing base (ec5b45b) to head (7259d35).
Report is 111 commits behind head on main.

Files with missing lines Patch % Lines
packages/vant/src/tab/TabTitle.tsx 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13431      +/-   ##
==========================================
+ Coverage   89.60%   89.71%   +0.10%     
==========================================
  Files         257      257              
  Lines        7013     7036      +23     
  Branches     1736     1746      +10     
==========================================
+ Hits         6284     6312      +28     
+ Misses        384      380       -4     
+ Partials      345      344       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some test cases for this change? Thanks

@YiMo1
Copy link
Author

YiMo1 commented Apr 14, 2025

Can you add some test cases for this change? Thanks

@chenjiahan 当然可以,不过我遇到一个错误,当badge为对象字面量时就会导致下面这个错误。如果badge为ref包裹的对象则没有这个问题。我目前正在解决这个,但进度不太理想,我可能要花一些时间。😞
最简单的办法就是不用对象的形式,就像和dot属性一样全都提取出来,但这样的话担心tab的属性会变得臃肿,你怎么认为?

<van-tabs>
  <van-tab :badge="{}" /> // Error: Maximum recursive updates exceeded in component <van-tabs>
</van-tabs>
<script>
const badge = ref({});
</script>

<template>
  <van-tabs>
    <van-tab :badge="badge" /> // No Error
  </van-tabs>
</template>

我在vue的练习场中复刻了这一行为:链接
我不确定这是否是Vue本身的问题,还是这种写法本就是不允许的。

@chenjiahan
Copy link
Member

看起来是循环触发渲染了,可能要加一些判断逻辑

@YiMo1 YiMo1 marked this pull request as draft June 3, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants