Przeglądaj źródła

fix: typo & defaultValues func context missing

YuanHeDx 10 miesięcy temu
rodzic
commit
6331f44570

+ 1 - 1
packages/node-engine/node/src/form-model-v2.ts

@@ -200,7 +200,7 @@ export class FormModelV2 extends FormModel implements Disposable {
     // 计算初始值: defaultValues 是默认表单值,不需要被format, 而rawInitialValues 是用户创建form 时传入的初始值,可能不同于表单数据格式,需要被format
     // 计算初始值: defaultValues 是默认表单值,不需要被format, 而rawInitialValues 是用户创建form 时传入的初始值,可能不同于表单数据格式,需要被format
     const defaultValues =
     const defaultValues =
       typeof formMeta.defaultValues === 'function'
       typeof formMeta.defaultValues === 'function'
-        ? formMeta.defaultValues()
+        ? formMeta.defaultValues(this.nodeContext)
         : formMeta.defaultValues;
         : formMeta.defaultValues;
 
 
     const initialValues = formMeta.formatOnInit
     const initialValues = formMeta.formatOnInit

+ 1 - 1
packages/node-engine/node/src/types.ts

@@ -95,7 +95,7 @@ export interface FormMeta<TValues = any> {
   /**
   /**
    * Form data's complete default value. it will not be sent to formatOnInit, but used directly as form's value when needed.
    * Form data's complete default value. it will not be sent to formatOnInit, but used directly as form's value when needed.
    */
    */
-  defaultValues?: TValues | ((contest: NodeContext) => TValues);
+  defaultValues?: TValues | ((context: NodeContext) => TValues);
   /**
   /**
    * This function is to format the value when initiate the form, the returned value will be used as the initial value of the form.
    * This function is to format the value when initiate the form, the returned value will be used as the initial value of the form.
    * @param value value input to node as initialValue.
    * @param value value input to node as initialValue.