@@ -9,6 +9,7 @@ import type { SizeType } from '../config-provider';
9
9
import isPlainObject from 'lodash-es/isPlainObject' ;
10
10
import useConfigInject from '../config-provider/hooks/useConfigInject' ;
11
11
import devWarning from '../vc-util/devWarning' ;
12
+ import useStyle from './style' ;
12
13
export interface CardTabListType {
13
14
key : string ;
14
15
tab : any ;
@@ -51,10 +52,12 @@ export type CardProps = Partial<ExtractPropTypes<ReturnType<typeof cardProps>>>;
51
52
const Card = defineComponent ( {
52
53
compatConfig : { MODE : 3 } ,
53
54
name : 'ACard' ,
55
+ inheritAttrs : false ,
54
56
props : cardProps ( ) ,
55
57
slots : [ 'title' , 'extra' , 'tabBarExtraContent' , 'actions' , 'cover' , 'customTab' ] ,
56
- setup ( props , { slots } ) {
58
+ setup ( props , { slots, attrs } ) {
57
59
const { prefixCls, direction, size } = useConfigInject ( 'card' , props ) ;
60
+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
58
61
const getAction = ( actions : VNodeTypes [ ] ) => {
59
62
const actionList = actions . map ( ( action , index ) =>
60
63
( isVNode ( action ) && ! isEmptyElement ( action ) ) || ! isVNode ( action ) ? (
@@ -99,6 +102,7 @@ const Card = defineComponent({
99
102
const pre = prefixCls . value ;
100
103
const classString = {
101
104
[ `${ pre } ` ] : true ,
105
+ [ hashId . value ] : true ,
102
106
[ `${ pre } -loading` ] : loading ,
103
107
[ `${ pre } -bordered` ] : bordered ,
104
108
[ `${ pre } -hoverable` ] : ! ! hoverable ,
@@ -190,13 +194,13 @@ const Card = defineComponent({
190
194
const actionDom =
191
195
actions && actions . length ? < ul class = { `${ pre } -actions` } > { getAction ( actions ) } </ ul > : null ;
192
196
193
- return (
194
- < div class = { classString } ref = "cardContainerRef" >
197
+ return wrapSSR (
198
+ < div ref = "cardContainerRef" { ... attrs } class = { classString } >
195
199
{ head }
196
200
{ coverDom }
197
201
{ children && children . length ? body : null }
198
202
{ actionDom }
199
- </ div >
203
+ </ div > ,
200
204
) ;
201
205
} ;
202
206
} ,
0 commit comments