tmagic-editor/docs/assets/api_form_form-methods.md.aycnh5FX.js
2026-06-04 09:22:54 +00:00

2 lines
4.8 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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) =&gt; Promise&lt;any&gt;</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&lt;any&gt;}</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) =&gt; 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) =&gt; string | undefined</code></p></li><li><p><strong>参数:</strong></p><ul><li><code>name: string</code> - 字段名,支持点分隔的路径格式,如 <code>&#39;a.b.c&#39;</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&lt;FormValue&gt;</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&lt;FormValue&gt;</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(&#39;mForm&#39;)</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&lt;boolean&gt;</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&lt;ChangeRecord[]&gt;</code></p></li><li><p><strong>详情:</strong> 表单变更记录列表,提交成功或重置后会被清空</p></li></ul>',19)])])}const p=o(l,[["render",i]]);export{m as __pageData,p as default};