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'
33export * from './watch'
44export * from './computed'
55export * from './inject'
6+ export { useCSSModule } from './useCssModule'
67export { createApp } from './createApp'
78export { nextTick } from './nextTick'
89export { 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