Skip to content
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

docs(components): add FAQ for showToast on-demand loading #13136

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

upthen
Copy link
Contributor

@upthen upthen commented Sep 25, 2024

#13109

按需引入组件时,使用 showToast 时出现样式异常问题?

在使用按需引入组件方案集成 vant 时,使用 showToast 等函数无需进行显式导入,否则会造成样式异常。

// 以下方式是不需要的
import { showToast } from 'vant'

这是因为在显式导入 showToast 等函数时, @vant/auto-import-resolver 将不会自动导入 Toast 的样式资源,这将导致 Toast 组件
的样式缺失,从而导致样式异常问题。

解决方案有2种:

  • 使用 showToast 时不进行显式导入;
  • 如果必须显示导入 showToast ,则同时需要手动导入 Toast 组件的相关样式。
import { showToast } from 'vant'
import 'vant/lib/toast/style'

@upthen upthen changed the title Docs/#13109 给 showToast 按需导入情况下使用时样式异常问题增加 FAQ 文档 docs(components): 给 showToast 按需导入情况下使用时样式异常问题增加 FAQ 文档 Sep 25, 2024
@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.68%. Comparing base (1f24cbc) to head (671525c).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13136      +/-   ##
==========================================
- Coverage   93.81%   89.68%   -4.13%     
==========================================
  Files         257      257              
  Lines        6999     6999              
  Branches     1730     1730              
==========================================
- Hits         6566     6277     -289     
- Misses        377      378       +1     
- Partials       56      344     +288     

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

@chenjiahan chenjiahan changed the title docs(components): 给 showToast 按需导入情况下使用时样式异常问题增加 FAQ 文档 docs(components): add FAQ for showToast on-demand loading Sep 27, 2024
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.

Thanks!

@chenjiahan chenjiahan enabled auto-merge (squash) September 27, 2024 13:13
@chenjiahan chenjiahan merged commit 4a72121 into youzan:main Sep 27, 2024
3 checks passed
@CherishTheYouth
Copy link

Thanks!

My Pleasure

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.

4 participants