mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 18:36:51 +08:00
types: using InjectionKey in composables (#8976)
This commit is contained in:
parent
5c080f3a6e
commit
8bc924ea62
@ -1,13 +1,10 @@
|
|||||||
import { inject, watch } from 'vue';
|
import { inject, InjectionKey, watch } from 'vue';
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
export const POPUP_TOGGLE_KEY = Symbol();
|
export const POPUP_TOGGLE_KEY: InjectionKey<() => boolean> = Symbol();
|
||||||
|
|
||||||
export function onPopupReopen(callback: () => void) {
|
export function onPopupReopen(callback: () => void) {
|
||||||
const popupToggleStatus = inject<(() => boolean) | null>(
|
const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
|
||||||
POPUP_TOGGLE_KEY,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
if (popupToggleStatus) {
|
if (popupToggleStatus) {
|
||||||
watch(popupToggleStatus, (show) => {
|
watch(popupToggleStatus, (show) => {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { inject, ComputedRef } from 'vue';
|
import { inject, ComputedRef, InjectionKey } from 'vue';
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
export const TAB_STATUS_KEY = Symbol();
|
export const TAB_STATUS_KEY: InjectionKey<ComputedRef<boolean>> = Symbol();
|
||||||
|
|
||||||
export function useTabStatus() {
|
export function useTabStatus() {
|
||||||
return inject<ComputedRef<boolean> | null>(TAB_STATUS_KEY, null);
|
return inject(TAB_STATUS_KEY, null);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user