@@ -9,6 +9,7 @@ import type { SizeType } from '../config-provider';
99import isPlainObject from 'lodash-es/isPlainObject' ;
1010import useConfigInject from '../config-provider/hooks/useConfigInject' ;
1111import devWarning from '../vc-util/devWarning' ;
12+ import useStyle from './style' ;
1213export interface CardTabListType {
1314 key : string ;
1415 tab : any ;
@@ -51,10 +52,12 @@ export type CardProps = Partial<ExtractPropTypes<ReturnType<typeof cardProps>>>;
5152const Card = defineComponent ( {
5253 compatConfig : { MODE : 3 } ,
5354 name : 'ACard' ,
55+ inheritAttrs : false ,
5456 props : cardProps ( ) ,
5557 slots : [ 'title' , 'extra' , 'tabBarExtraContent' , 'actions' , 'cover' , 'customTab' ] ,
56- setup ( props , { slots } ) {
58+ setup ( props , { slots, attrs } ) {
5759 const { prefixCls, direction, size } = useConfigInject ( 'card' , props ) ;
60+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
5861 const getAction = ( actions : VNodeTypes [ ] ) => {
5962 const actionList = actions . map ( ( action , index ) =>
6063 ( isVNode ( action ) && ! isEmptyElement ( action ) ) || ! isVNode ( action ) ? (
@@ -99,6 +102,7 @@ const Card = defineComponent({
99102 const pre = prefixCls . value ;
100103 const classString = {
101104 [ `${ pre } ` ] : true ,
105+ [ hashId . value ] : true ,
102106 [ `${ pre } -loading` ] : loading ,
103107 [ `${ pre } -bordered` ] : bordered ,
104108 [ `${ pre } -hoverable` ] : ! ! hoverable ,
@@ -190,13 +194,13 @@ const Card = defineComponent({
190194 const actionDom =
191195 actions && actions . length ? < ul class = { `${ pre } -actions` } > { getAction ( actions ) } </ ul > : null ;
192196
193- return (
194- < div class = { classString } ref = "cardContainerRef" >
197+ return wrapSSR (
198+ < div ref = "cardContainerRef" { ... attrs } class = { classString } >
195199 { head }
196200 { coverDom }
197201 { children && children . length ? body : null }
198202 { actionDom }
199- </ div >
203+ </ div > ,
200204 ) ;
201205 } ;
202206 } ,
0 commit comments