File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ export * from './lifecycle'
3
3
export * from './watch'
4
4
export * from './computed'
5
5
export * from './inject'
6
+ export { useCSSModule } from './useCssModule'
6
7
export { createApp } from './createApp'
7
8
export { nextTick } from './nextTick'
8
9
export { createElement as h } from './createElement'
Original file line number Diff line number Diff line change
1
+ import { getCurrentInstance } from '../runtimeContext'
2
+ import { warn } from '../utils'
3
+
4
+ const EMPTY_OBJ : { readonly [ key : string ] : string } = __DEV__
5
+ ? Object . freeze ( { } )
6
+ : { }
7
+
8
+ export const useCSSModule = ( name = '$style' ) : Record < string , string > => {
9
+ const instance = getCurrentInstance ( )
10
+ if ( ! instance ) {
11
+ __DEV__ && warn ( `useCSSModule must be called inside setup()` )
12
+ return EMPTY_OBJ
13
+ }
14
+
15
+ const mod = ( instance as any ) [ name ]
16
+ if ( ! mod ) {
17
+ __DEV__ &&
18
+ warn ( `Current instance does not have CSS module named "${ name } ".` )
19
+ return EMPTY_OBJ
20
+ }
21
+
22
+ return mod as Record < string , string >
23
+ }
You can’t perform that action at this time.
0 commit comments