Skip to content
This repository was archived by the owner on May 2, 2024. It is now read-only.

Commit cc8329f

Browse files
committed
fix: Add fallback values to Composition API methods
1 parent 91387f7 commit cc8329f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/use.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ import { getCurrentInstance } from 'vue'
1313
*/
1414
export function useData () {
1515
const app = getCurrentInstance()
16-
return app.appContext.config.globalProperties.$data
16+
return app?.appContext.config.globalProperties.$data ?? {}
1717
}
1818

1919
/**
2020
* @returns {Object<string,function>}
2121
*/
2222
export function useMethods () {
2323
const app = getCurrentInstance()
24-
return app.appContext.config.globalProperties.$methods
24+
return app?.appContext.config.globalProperties.$methods ?? {}
2525
}
2626

2727
/**
28-
* @returns {string}
28+
* @returns {string|null}
2929
*/
3030
export function useCSS () {
3131
const app = getCurrentInstance()
32-
return app.appContext.config.globalProperties.$css
32+
return app?.appContext.config.globalProperties.$css
3333
}

0 commit comments

Comments
 (0)