-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix: 解决 vue 组件未兼容繁体的问题 #7044
Merged
Merged
fix: 解决 vue 组件未兼容繁体的问题 #7044
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个代码片段在2023年之前就已经过时了。请注意以下几点:
去掉
import
部分(除了注释外)因为它们已经不再需要,因为它已经被使用过的reactive
,computed
,ref
,nextTick
等库替代。在组件初始化后添加
useTheme()
是可以被更高效地优化的。这将减少不必要的计算,并有助于提升性能。使用语言配置文件来保持跨平台一致性的处理是很推荐的做法。
这里提供了一个更新后的示例:
上述代码块定义了一个名为「localI18n」的状态,它负责维护一个已加载到本地存储的 I18N 属性或其值(如果已有)。一旦用户切换至特定语言,将其设为该键的值并重新写入localStorage以供下次访问时可读取。
此策略的优点是更加独立且无需对整个应用程序结构进行调整。