We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
2.2.0-beta.2
mac os 10.15.6, chrome 87.0.4280.141, vue 3.1.1
https://github.com/jackhe16/antdv-select-attrs-class
见 https://github.com/jackhe16/antdv-select-attrs-class
更新Select组件的class应该生效
更新Select组件的class没有生效
vue3官网中有相关描述
attrs 和 slots 是有状态的对象,它们总是会随组件本身的更新而更新。这意味着你应该避免对它们进行解构,并始终以 attrs.x 或 slots.x 的方式引用 property。请注意,与 props 不同,attrs 和 slots 是非响应式的。如果你打算根据 attrs 或 slots 更改应用副作用,那么应该在 onUpdated 生命周期钩子中执行此操作。
Select组件源码相关代码
const mergedClassName = computed(() => classNames( { [`${prefixCls.value}-lg`]: props.size === 'large', [`${prefixCls.value}-sm`]: props.size === 'small', [`${prefixCls.value}-rtl`]: props.direction === 'rtl', [`${prefixCls.value}-borderless`]: !props.bordered, }, attrs.class, ), );
setup中监听不到attrs.class的变化, 因此更新class没有生效。
有以下几种解决思路
const mergedClassName = ref(classNames( { [`${prefixCls.value}-lg`]: props.size === 'large', [`${prefixCls.value}-sm`]: props.size === 'small', [`${prefixCls.value}-rtl`]: props.direction === 'rtl', [`${prefixCls.value}-borderless`]: !props.bordered, }, attrs.class, )); onUpdated(() => { mergedClassName.value = classNames( { [`${prefixCls.value}-lg`]: props.size === 'large', [`${prefixCls.value}-sm`]: props.size === 'small', [`${prefixCls.value}-rtl`]: props.direction === 'rtl', [`${prefixCls.value}-borderless`]: !props.bordered, }, attrs.class, ) });
mergedClassName计算放到render中
参考element-plus useAttrs
The text was updated successfully, but these errors were encountered:
fix: select class not update #4194
74b66ec
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Sorry, something went wrong.
No branches or pull requests
Version
2.2.0-beta.2
Environment
mac os 10.15.6, chrome 87.0.4280.141, vue 3.1.1
Reproduction link
https://github.com/jackhe16/antdv-select-attrs-class
Steps to reproduce
见 https://github.com/jackhe16/antdv-select-attrs-class
What is expected?
更新Select组件的class应该生效
What is actually happening?
更新Select组件的class没有生效
vue3官网中有相关描述
Select组件源码相关代码
setup中监听不到attrs.class的变化, 因此更新class没有生效。
有以下几种解决思路
mergedClassName计算放到render中
参考element-plus useAttrs
The text was updated successfully, but these errors were encountered: