mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-06-05 01:32:10 +08:00
2 lines
4.8 KiB
JavaScript
2 lines
4.8 KiB
JavaScript
import{ax as o,z as a,A as r,b5 as t}from"./chunks/framework.V2ssSR2R.js";const m=JSON.parse('{"title":"Form组件 methods","description":"","frontmatter":{},"headers":[],"relativePath":"api/form/form-methods.md","filePath":"api/form/form-methods.md"}'),l={name:"api/form/form-methods.md"};function i(n,e,s,d,c,h){return r(),a("div",null,[...e[0]||(e[0]=[t('<h1 id="form组件-methods" tabindex="-1">Form组件 methods <a class="header-anchor" href="#form组件-methods" aria-label="Permalink to “Form组件 methods”"></a></h1><h2 id="resetform" tabindex="-1">resetForm <a class="header-anchor" href="#resetform" aria-label="Permalink to “resetForm”"></a></h2><ul><li><strong>详情:</strong> 重置该表单项,将其值重置为初始值,并移除校验结果</li></ul><h2 id="submitform" tabindex="-1">submitForm <a class="header-anchor" href="#submitform" aria-label="Permalink to “submitForm”"></a></h2><ul><li><p><strong>签名:</strong> <code>async (native?: boolean) => Promise<any></code></p></li><li><p><strong>参数:</strong></p><ul><li><code>native?: boolean</code> - 是否返回原始表单值。当 <code>native</code> 为 <code>true</code> 时返回内部 <code>values.value</code>(响应式原值);否则返回 <code>cloneDeep(toRaw(values.value))</code>(深拷贝后的纯对象)</li></ul></li><li><p><strong>返回:</strong></p><ul><li><code>{Promise<any>}</code> - 校验通过后返回当前表单值;校验失败时会触发 <code>error</code> 事件并 throw 一个包含错误信息的 <code>Error</code></li></ul></li><li><p><strong>详情:</strong> 提交表单,先执行校验,校验通过后清空 <code>changeRecords</code> 并返回当前表单值</p></li><li><p><strong>相关:</strong> 如果你想脱离组件树以函数方式完成一次表单提交,参见 <a href="./submit-form.html"><code>submitForm</code> 函数</a></p></li></ul><h2 id="changehandler" tabindex="-1">changeHandler <a class="header-anchor" href="#changehandler" aria-label="Permalink to “changeHandler”"></a></h2><ul><li><p><strong>签名:</strong> <code>(prop: string, value: any, eventData?: ContainerChangeEventData) => void</code></p></li><li><p><strong>详情:</strong> 表单项值变更处理函数,会根据传入的 <code>propPath</code> 更新内部表单值,并向上 emit <code>change</code> 事件</p></li></ul><h2 id="gettextbyname" tabindex="-1">getTextByName <a class="header-anchor" href="#gettextbyname" aria-label="Permalink to “getTextByName”"></a></h2><ul><li><p><strong>签名:</strong> <code>(name: string) => string | undefined</code></p></li><li><p><strong>参数:</strong></p><ul><li><code>name: string</code> - 字段名,支持点分隔的路径格式,如 <code>'a.b.c'</code></li></ul></li><li><p><strong>返回:</strong></p><ul><li><code>{string | undefined}</code> - 找到的 <code>text</code> 值,如果未找到则返回 <code>undefined</code></li></ul></li><li><p><strong>详情:</strong> 通过 <code>name</code> 从表单 <code>config</code> 中查找对应表单项的 <code>text</code></p></li></ul><h2 id="values" tabindex="-1">values <a class="header-anchor" href="#values" aria-label="Permalink to “values”"></a></h2><ul><li><p><strong>类型:</strong> <code>Ref<FormValue></code></p></li><li><p><strong>详情:</strong> 当前表单值的响应式引用</p></li></ul><h2 id="lastvaluesprocessed" tabindex="-1">lastValuesProcessed <a class="header-anchor" href="#lastvaluesprocessed" aria-label="Permalink to “lastValuesProcessed”"></a></h2><ul><li><p><strong>类型:</strong> <code>Ref<FormValue></code></p></li><li><p><strong>详情:</strong> 对比模式下,处理后的待对比表单值</p></li></ul><h2 id="formstate" tabindex="-1">formState <a class="header-anchor" href="#formstate" aria-label="Permalink to “formState”"></a></h2><ul><li><p><strong>类型:</strong> <code>FormState</code></p></li><li><p><strong>详情:</strong> 内部使用的 formState 对象(<code>reactive</code>),通过 <code>provide('mForm')</code> 注入给子组件</p></li></ul><h2 id="initialized" tabindex="-1">initialized <a class="header-anchor" href="#initialized" aria-label="Permalink to “initialized”"></a></h2><ul><li><p><strong>类型:</strong> <code>Ref<boolean></code></p></li><li><p><strong>详情:</strong> 表单是否已经完成初始化</p></li></ul><h2 id="changerecords" tabindex="-1">changeRecords <a class="header-anchor" href="#changerecords" aria-label="Permalink to “changeRecords”"></a></h2><ul><li><p><strong>类型:</strong> <code>ShallowRef<ChangeRecord[]></code></p></li><li><p><strong>详情:</strong> 表单变更记录列表,提交成功或重置后会被清空</p></li></ul>',19)])])}const p=o(l,[["render",i]]);export{m as __pageData,p as default};
|