ZN
8 天以前 e756e3cc5ddd0ddb42c5f00d6bb3eee76ba73e6f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { reactive } from "vue";
import { deepClone } from "@/utils/index.js"
 
export default function useFormData(initData) {
  const form = reactive(deepClone(initData, true));
 
  function resetForm() {
    const initData2 = JSON.parse(JSON.stringify(initData));
    Object.keys(initData).forEach(key => {
      form[key] = initData2[key];
    });
  }
 
  return { form, resetForm };
}