Skip to content

Conversation

@984507092
Copy link

把 cn 从 HTML 中提取出来,使用 computed 进行包裹,减少重复计算

@pkc918
Copy link
Contributor

pkc918 commented Dec 8, 2025

这里需要这样么?

  • 明明简单的字符串拼接,现在给添加一些effect
  • class的变化,都可能会重绘,重排了,为什么需要这个effect

我感觉这里就是无端增加一些开销,仅此而已

@984507092
Copy link
Author

这里需要这样么?

  • 明明简单的字符串拼接,现在给添加一些effect
  • class的变化,都可能会重绘,重排了,为什么需要这个effect

我感觉这里就是无端增加一些开销,仅此而已

只有当 props.class 变化时,cn 才会被重新执行
在模板中写 :class="cn()" 每次 render 都重新执行
重绘、重排只有在 DOM 发现变化或者样式发生变化、插入节点或者移除节点吧
如果对比开销 effect 的开销远比模板写法开销小的吧

@cwandev
Copy link
Collaborator

cwandev commented Dec 9, 2025

Thanks for the PR @984507092!

The current class pattern in the component library will remain as is, and this change doesn’t bring much improvement to the overall structure. So we won’t be merging it for now.

Still, we really appreciate your contribution and interest in the project!

@cwandev cwandev closed this Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants