liuyu
7 小时以前 82a74ba0402ab546ba524d23ce62198c4d00d2f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import type { InjectionKey } from 'vue';
 
import { createContext, useContext } from '@jnpf/hooks';
 
export interface FormContextProps {
  resetAction: () => Promise<void>;
  submitAction: () => Promise<void>;
}
 
const key: InjectionKey<FormContextProps> = Symbol('key');
 
export function createFormContext(context: FormContextProps) {
  return createContext<FormContextProps>(context, key);
}
 
export function useFormContext() {
  return useContext<FormContextProps>(key);
}